Skip to content

Commit

Permalink
feat: 🎸 使用外置环境变量的方式来部署服务
Browse files Browse the repository at this point in the history
  • Loading branch information
monlor committed Jun 1, 2024
1 parent 46508bc commit 822974b
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 68 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,24 @@
bash -c "$(curl -fsSL https://raw.githubusercontent.com/monlor/docker-xiaoya/main/install.sh)"
```

使用加速源(我的加速源也可能帮你减速🤣)

```bash
export GH_PROXY=https://gh.monlor.com/ IMAGE_PROXY=ghcr.monlor.com && bash -c "$(curl -fsSL ${GH_PROXY}https://raw.githubusercontent.com/monlor/docker-xiaoya/main/install.sh)"
```

### 卸载脚本

```bash
bash -c "$(curl -fsSL https://raw.githubusercontent.com/monlor/docker-xiaoya/main/uninstall.sh)"
```

使用加速源(我的加速源也可能帮你减速🤣)

```bash
export GH_PROXY=https://gh.monlor.com/ IMAGE_PROXY=ghcr.monlor.com && bash -c "$(curl -fsSL ${GH_PROXY}https://raw.githubusercontent.com/monlor/docker-xiaoya/main/uninstall.sh)"
```

## 部署配置推荐

| 部署方案 | CPU | 内存 | 硬盘 |
Expand Down
10 changes: 2 additions & 8 deletions docker-compose-alist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,8 @@ services:
- "5678:5678"
- "2345:2345"
- "2346:2346"
environment:
- TZ=Asia/Shanghai
- ALIYUN_TOKEN=
- ALIYUN_OPEN_TOKEN=
- ALIYUN_FOLDER_ID=
- AUTO_UPDATE_ENABLED=true
- AUTO_CLEAR_ENABLED=true
- AUTO_UPDATE_MEDIA_ADDR=false
env_file:
- env
restart: unless-stopped
networks:
- default
Expand Down
25 changes: 8 additions & 17 deletions docker-compose-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,18 @@ services:
- "5678:5678"
- "2345:2345"
- "2346:2346"
environment:
- TZ=Asia/Shanghai
- ALIYUN_TOKEN=
- ALIYUN_OPEN_TOKEN=
- ALIYUN_FOLDER_ID=
- AUTO_UPDATE_ENABLED=true
- AUTO_CLEAR_ENABLED=true
env_file:
- env
restart: unless-stopped
networks:
- default
metadata:
image: ghcr.io/monlor/xiaoya-metadata
environment:
- LANG=C.UTF-8
# - ALIST_ADDR=http://alist:5678
- EMBY_ENABLED=true
- JELLYFIN_ENABLED=true
- AUTO_UPDATE_EMBY_CONFIG_ENABLED=true
env_file:
- env
volumes:
- xiaoya:/etc/xiaoya
- media:/media/xiaoya
Expand All @@ -39,10 +33,8 @@ services:
- default
emby:
image: ghcr.io/monlor/xiaoya-emby
environment:
- TZ=Asia/Shanghai
- GIDLIST=0
# ALIST_ADDR=http://alist:5678
env_file:
- env
privileged: true
devices:
- /dev/dri:/dev/dri
Expand Down Expand Up @@ -76,9 +68,8 @@ services:
- default
jellyfin:
image: ghcr.io/monlor/xiaoya-jellyfin
environment:
- TZ=Asia/Shanghai
# ALIST_ADDR=http://alist:5678
env_file:
- env
privileged: true
devices:
- /dev/dri:/dev/dri
Expand Down
19 changes: 6 additions & 13 deletions docker-compose-jellyfin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,18 @@ services:
- "5678:5678"
- "2345:2345"
- "2346:2346"
environment:
- TZ=Asia/Shanghai
- ALIYUN_TOKEN=
- ALIYUN_OPEN_TOKEN=
- ALIYUN_FOLDER_ID=
- AUTO_UPDATE_ENABLED=true
- AUTO_CLEAR_ENABLED=true
env_file:
- env
restart: unless-stopped
networks:
- default
metadata:
image: ghcr.io/monlor/xiaoya-metadata
environment:
- LANG=C.UTF-8
# - ALIST_ADDR=http://alist:5678
- EMBY_ENABLED=false
- JELLYFIN_ENABLED=true
- AUTO_UPDATE_EMBY_CONFIG_ENABLED=true
env_file:
- env
volumes:
- xiaoya:/etc/xiaoya
- media:/media/xiaoya
Expand All @@ -39,9 +33,8 @@ services:
- default
jellyfin:
image: ghcr.io/monlor/xiaoya-jellyfin
environment:
- TZ=Asia/Shanghai
# ALIST_ADDR=http://alist:5678
env_file:
- env
privileged: true
devices:
- /dev/dri:/dev/dri
Expand Down
29 changes: 8 additions & 21 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,15 @@ services:
- "5678:5678"
- "2345:2345"
- "2346:2346"
environment:
- TZ=Asia/Shanghai
- ALIYUN_TOKEN=
- ALIYUN_OPEN_TOKEN=
- ALIYUN_FOLDER_ID=
- AUTO_UPDATE_ENABLED=true
- AUTO_CLEAR_ENABLED=true
# - EMBY_ADDR=http://emby:6908
env_file:
- env
restart: unless-stopped
networks:
- default
metadata:
image: ghcr.io/monlor/xiaoya-metadata
environment:
- LANG=C.UTF-8
# - ALIST_ADDR=http://alist:5678
# - EMBY_ADDR=http://emby:6908
- EMBY_ENABLED=true
- JELLYFIN_ENABLED=false
- AUTO_UPDATE_EMBY_CONFIG_ENABLED=true
env_file:
- env
volumes:
- xiaoya:/etc/xiaoya
- media:/media/xiaoya
Expand All @@ -42,10 +31,8 @@ services:
- default
emby:
image: ghcr.io/monlor/xiaoya-emby
environment:
- TZ=Asia/Shanghai
- GIDLIST=0
# ALIST_ADDR=http://alist:5678
env_file:
- env
privileged: true
devices:
- /dev/dri:/dev/dri
Expand All @@ -63,8 +50,8 @@ services:
- default
resilio:
image: ghcr.io/monlor/xiaoya-resilio
environment:
- TZ=Asia/Shanghai
env_file:
- env
ports:
- 8888:8888
- 55555:55555
Expand Down
35 changes: 35 additions & 0 deletions env
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
TZ=Asia/Shanghai
# 阿里云盘token
ALIYUN_TOKEN=
# 阿里云盘open token
ALIYUN_OPEN_TOKEN=
# 阿里云盘文件夹ID
ALIYUN_FOLDER_ID=
# 自动更新小雅alist文件
AUTO_UPDATE_ENABLED=true
# 自动清理阿里云盘
AUTO_CLEAR_ENABLED=true
# 阿里云盘自动清理间隔,单位小时,默认24小时
AUTO_CLEAR_INTERVAL=24
# pikpak 账号列表,格式:`qqq@qq.com:aaadds,+8613111111111:dasf`,密码中不支持符号,:
PIKPAK_LIST=
# 开启登陆功能,true/false
FORCE_LOGIN=
# webdav用户名为dav,设置密码。默认用户密码:guest/guest_Api789
WEBDAV_PASSWORD=

# emby 地址
EMBY_ADDR=http://emby:6908
# alist 地址
ALIST_ADDR=http://alist:5678

# 是否启用emby
EMBY_ENABLED=true
# 是否启用jellyfin
JELLYFIN_ENABLED=false
# 自动更新emby的配置,依赖EMBY_APIKEY
AUTO_UPDATE_EMBY_CONFIG_ENABLED=true
# 自动更新emby配置,config.mp4间隔,单位天,默认7天
AUTO_UPDATE_EMBY_INTERVAL=7
# emby的apikey
EMBY_APIKEY=e825ed6f7f8f44ffa0563cddaddce14d
29 changes: 21 additions & 8 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ else
SED_COMMAND='sed -i'
fi

# 格式https://xxx.com/
GH_PROXY="${GH_PROXY:=}"
# 格式xxx.com
IMAGE_PROXY="${IMAGE_PROXY:=}"

# 欢迎信息
echo "欢迎使用xiaoya服务部署脚本"
echo "项目地址:https://github.com/monlor/docker-xiaoya"
Expand Down Expand Up @@ -51,7 +56,7 @@ if ! docker compose &> /dev/null && ! which docker-compose &> /dev/null; then
echo "不支持的系统架构$(uname -m), 请自行安装docker compose(https://docs.docker.com/compose/install/linux/#install-using-the-repository)"
exit 1
fi
curl -SL https://github.com/docker/compose/releases/download/v2.27.1/$file -o /usr/local/bin/docker-compose
curl -SL "${GH_PROXY}https://github.com/docker/compose/releases/download/v2.27.1/$file" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
else
echo "退出安装"
Expand Down Expand Up @@ -80,9 +85,9 @@ fi

# 如果是更新服务,则从原有的compose配置中获取token等信息
if [ "${update}" = "y" ]; then
token=$(cat $install_path/docker-compose.yml | grep ALIYUN_TOKEN | awk -F '=' '{print $2}')
open_token=$(cat $install_path/docker-compose.yml | grep ALIYUN_OPEN_TOKEN | awk -F '=' '{print $2}')
folder_id=$(cat $install_path/docker-compose.yml | grep ALIYUN_FOLDER_ID | awk -F '=' '{print $2}')
token=$(cat $install_path/env 2> /dev/null | grep ALIYUN_TOKEN | awk -F '=' '{print $2}')
open_token=$(cat $install_path/env 2> /dev/null | grep ALIYUN_OPEN_TOKEN | awk -F '=' '{print $2}')
folder_id=$(cat $install_path/env 2> /dev/null | grep ALIYUN_FOLDER_ID | awk -F '=' '{print $2}')
fi

# 让用户输入阿里云盘TOKEN,token获取方式教程:https://alist.nn.ci/zh/guide/drivers/aliyundrive.html
Expand Down Expand Up @@ -150,10 +155,17 @@ fi
cd $install_path

echo "开始生成配置文件docker-compose${service_type}.yml..."
curl -#Lo $install_path/docker-compose.yml https://raw.githubusercontent.com/monlor/docker-xiaoya/main/docker-compose${service_type}.yml
$SED_COMMAND "s#ALIYUN_TOKEN=.*#ALIYUN_TOKEN=$token#g" docker-compose.yml
$SED_COMMAND "s#ALIYUN_OPEN_TOKEN=.*#ALIYUN_OPEN_TOKEN=$open_token#g" docker-compose.yml
$SED_COMMAND "s#ALIYUN_FOLDER_ID=.*#ALIYUN_FOLDER_ID=$folder_id#g" docker-compose.yml
curl -#Lo $install_path/docker-compose.yml "${GH_PROXY}https://raw.githubusercontent.com/monlor/docker-xiaoya/main/docker-compose${service_type}.yml"
if [ ! -f $install_path/env ]; then
curl -#Lo $install_path/env "${GH_PROXY}https://raw.githubusercontent.com/monlor/docker-xiaoya/main/env"
fi
$SED_COMMAND "s#ALIYUN_TOKEN=.*#ALIYUN_TOKEN=$token#g" env
$SED_COMMAND "s#ALIYUN_OPEN_TOKEN=.*#ALIYUN_OPEN_TOKEN=$open_token#g" env
$SED_COMMAND "s#ALIYUN_FOLDER_ID=.*#ALIYUN_FOLDER_ID=$folder_id#g" env

if [ -n "$IMAGE_PROXY" ]; then
$SED_COMMAND -E "s#image: [^/]+#image: ${IMAGE_PROXY}#g" docker-compose.yml
fi

echo "开始部署服务..."
$DOCKER_COMPOSE -f docker-compose.yml up --remove-orphans --pull=always -d
Expand All @@ -168,6 +180,7 @@ echo "查看日志:$DOCKER_COMPOSE -f $install_path/docker-compose.yml logs -f
echo "启动服务:$DOCKER_COMPOSE -f $install_path/docker-compose.yml start"
echo "重启服务:$DOCKER_COMPOSE -f $install_path/docker-compose.yml restart"
echo "停止服务:$DOCKER_COMPOSE -f $install_path/docker-compose.yml down"
echo "高级用户自定义配置:$install_path/env"

# 获取当前服务器ip
ip=$(curl -s ip.sb 2> /dev/null)
Expand Down
2 changes: 1 addition & 1 deletion metadata/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ cron

crontabs=""

if [ "${AUTO_UPDATE_EMBY_CONFIG_ENABLED:=false}" = "true" ]; then
if [ "${AUTO_UPDATE_EMBY_CONFIG_ENABLED:=false}" = "true" ] && [ "${EMBY_ENABLED}" = "true" ]; then
echo "启动定时更新Emby任务..."
crontabs="0 3 */${AUTO_UPDATE_EMBY_INTERVAL:=7} * * /emby.sh update"
fi
Expand Down

0 comments on commit 822974b

Please sign in to comment.