一 、docker 部署 xiaomusic 小爱音箱

xiaomusic_GitHub地址:https://github.com/hanxi/xiaomusic
xiaomusic_后台地址:http://localhost:8393

1 、Debian 终端命令创建docker-compose.yml文件

  • 我的歌曲目录/mnt/file/music
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
mkdir -p /mnt/mydisk/home/xiaomusic && \
cd /mnt/mydisk/home/xiaomusic && \
touch docker-compose.yml && \
cat > docker-compose.yml <<'EOF'
services:
xiaomusic:
image: m.daocloud.io/docker.io/hanxi/xiaomusic ## 国内镜像名称
## image: hanxi/xiaomusic ## 国外镜像名称
container_name: xiaomusic ## 容器名称(可修改)
restart: unless-stopped ## 重启策略
ports:
- 8393:8090 ## 端口映射
volumes:
- /mnt/file/music:/app/music ## 本地歌曲路径
- ./conf:/app/conf ## 配置文件路径
environment:
XIAOMUSIC_PUBLIC_PORT: 8393
EOF

docker-compose up -d

2 、拉取并运行

1
cd /mnt/mydisk/home/xiaomusic && docker-compose up -d

3 、停止并删除

1
cd /mnt/mydisk/home/xiaomusic && docker-compose down

4 、拉取镜像

1
docker pull m.daocloud.io/docker.io/hanxi/xiaomusic

5 、容器升级

1
cd /mnt/mydisk/home/xiaomusic && docker-compose down && docker-compose pull && docker-compose up -d && docker image prune -f

二 、容器维护命令

1 、查看所有运行容器的名称

1
docker ps -a --format "{{.Names}}"

2 、停止 xiaomusic 容器

1
docker stop xiaomusic

3 、启动 xiaomusic 容器

1
docker start xiaomusic

4 、重启 xiaomusic 容器

1
docker restart xiaomusic

5 、进入 xunlei 容器

1
2
3
## Ctrl+D 退出容器
## docker exec -it xiaomusic sh
docker exec -it xiaomusic bash

6 、查看 xiaomusic 配置文件

1
cat /mnt/mydisk/home/xiaomusic/docker-compose.yml

三 、更新音乐列表

  1. music 文件夹新增音乐文件
  2. 重启 xiaomusic 容器:docker restart xiaomusic
  3. xiaomusic 后台操作
    • 设置
    • 点击-重新拉取设置数据
    • 点击-拉取最新的音乐列表
    • 点击-刷新音乐标签

我的 xiaomusic 音乐库

克隆仓库

1
git clone git@gitee.com:meimolihan/xiaomusic-music.git

我的音乐库目录(FnOS)

1
2
cd /vol2/1000/file/music && \
bash <(curl -sL gitee.com/meimolihan/script/raw/master/sh/git/git_push.sh)

Nginx 配置

后台地址:https://xiaomusic.example.com:666

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
mkdir -pm 755 /etc/nginx/conf.d && \
touch /etc/nginx/conf.d/xiaomusic.conf && \
cat <<'EOF' | sed '1!{/^[[:space:]]*#/d;/^[[:space:]]*$/d}' > /etc/nginx/conf.d/xiaomusic.conf
## nginx 反向代理: xiaomusic 小爱音箱
server {
## 监听666端口,并启用SSL
listen 666 ssl;
listen [::]:666 ssl;

## 替换为你的域名
server_name xiaomusic.example.com;

## 指定 SSL 证书文件和私钥文件的路径
ssl_certificate /etc/nginx/keyfile/cert.pem;
ssl_certificate_key /etc/nginx/keyfile/key.pem;
## 设置支持的SSL‮议协‬版本
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
# 启用服‮器务‬端加密套件优先
ssl_prefer_server_ciphers on;
## 设置加密套件,优先用‮强高‬度加密算法,并排‮匿除‬名加‮套密‬件和MD5散列算法
ssl_ciphers HIGH:!aNULL:!MD5;

location / {
## 指定反向代理的服务地址
proxy_pass http://10.10.10.251:8393;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Range $http_range;
proxy_set_header If-Range $http_if_range;
proxy_redirect off;
## 开启缓存
proxy_buffering on;
## 使用 HTTP/1.1 协议通信
proxy_http_version 1.1;
}
## 错误处理
charset utf-8; ## 添加这行来指定编码
error_page 404 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/html;
}
}
EOF

sudo systemctl restart nginx