[update] docker support v1/v2

This commit is contained in:
Lkeme 2022-08-22 18:07:45 +08:00
parent 182d7d4df8
commit c69b903ca2
3 changed files with 79 additions and 47 deletions

View File

@ -8,7 +8,9 @@ ENV USER_NAME='' \
REPO_URL='https://github.com/' \
CUSTOM_CLONE_URL='https://speed.example.com/example/example.git' \
MIRRORS="0" \
CONIFG_PATH='/app/profile/user/config/user.ini' \
VERSION="2"
V1_CONIFG_PATH='/app/conf/user.ini' \
V2_CONIFG_PATH='/app/profile/user/config/user.ini' \
Green="\\033[32m" \
Red="\\033[31m" \
GreenBG="\\033[42;37m" \
@ -53,4 +55,4 @@ RUN apk add --no-cache git && \
rm -r /var/cache/apk && \
rm -r /usr/share/man
ENTRYPOINT ["entrypoint.sh"]
ENTRYPOINT ["entrypoint.sh"]

View File

@ -4,49 +4,49 @@ set -e
# 源切换
case ${MIRRORS} in
"custom")
# custom
echo -e "\n ======== \n ${Info} ${GreenBG} 切换源-自定义克隆链接 ${Font} \n ======== \n"
git remote set-url origin ${CUSTOM_CLONE_URL}
;;
# custom
echo -e "\n ======== \n ${Info} ${GreenBG} 切换源-自定义克隆链接 ${Font} \n ======== \n"
git remote set-url origin ${CUSTOM_CLONE_URL}
;;
"0")
# https://github.com/
echo -e "\n ======== \n ${Info} ${GreenBG} 切换源-github.com ${Font} \n ======== \n"
git remote set-url origin https://github.com/lkeme/BiliHelper-personal.git
;;
# https://github.com/
echo -e "\n ======== \n ${Info} ${GreenBG} 切换源-github.com ${Font} \n ======== \n"
git remote set-url origin https://github.com/lkeme/BiliHelper-personal.git
;;
"1")
# https://ghproxy.com/
echo -e "\n ======== \n ${Info} ${GreenBG} 切换源-ghproxy.com ${Font} \n ======== \n"
git remote set-url origin https://ghproxy.com/https://github.com/lkeme/BiliHelper-personal.git
;;
# https://ghproxy.com/
echo -e "\n ======== \n ${Info} ${GreenBG} 切换源-ghproxy.com ${Font} \n ======== \n"
git remote set-url origin https://ghproxy.com/https://github.com/lkeme/BiliHelper-personal.git
;;
"2")
# http://fastgit.org/
echo -e "\n ======== \n ${Info} ${GreenBG} 切换源-hub.fastgit.xyz ${Font} \n ======== \n"
git remote set-url origin https://hub.fastgit.xyz/lkeme/BiliHelper-personal.git
;;
# http://fastgit.org/
echo -e "\n ======== \n ${Info} ${GreenBG} 切换源-hub.fastgit.xyz ${Font} \n ======== \n"
git remote set-url origin https://hub.fastgit.xyz/lkeme/BiliHelper-personal.git
;;
"3")
# https://hub.gitfast.tk/
echo -e "\n ======== \n ${Info} ${GreenBG} 切换源-hub.gitfast.tk ${Font} \n ======== \n"
git remote set-url origin https://hub.gitfast.tk/lkeme/BiliHelper-personal.git
;;
# https://hub.gitfast.tk/
echo -e "\n ======== \n ${Info} ${GreenBG} 切换源-hub.gitfast.tk ${Font} \n ======== \n"
git remote set-url origin https://hub.gitfast.tk/lkeme/BiliHelper-personal.git
;;
"4")
# https://hub.gitslow.tk/
echo -e "\n ======== \n ${Info} ${GreenBG} 切换源-hub.gitslow.tk ${Font} \n ======== \n"
git remote set-url origin https://hub.gitslow.tk/lkeme/BiliHelper-personal.git
;;
# https://hub.gitslow.tk/
echo -e "\n ======== \n ${Info} ${GreenBG} 切换源-hub.gitslow.tk ${Font} \n ======== \n"
git remote set-url origin https://hub.gitslow.tk/lkeme/BiliHelper-personal.git
;;
"5")
# https://hub.verge.tk/
echo -e "\n ======== \n ${Info} ${GreenBG} 切换源-hub.verge.tk ${Font} \n ======== \n"
git remote set-url origin https://hub.verge.tk/lkeme/BiliHelper-personal.git
;;
# https://hub.verge.tk/
echo -e "\n ======== \n ${Info} ${GreenBG} 切换源-hub.verge.tk ${Font} \n ======== \n"
git remote set-url origin https://hub.verge.tk/lkeme/BiliHelper-personal.git
;;
"6")
# https://gh.api.99988866.xyz/
echo -e "\n ======== \n ${Info} ${GreenBG} 切换源-gh.api.99988866.xyz ${Font} \n ======== \n"
git remote set-url origin https://gh.api.99988866.xyz/https://github.com/lkeme/BiliHelper-personal.git
;;
# https://gh.api.99988866.xyz/
echo -e "\n ======== \n ${Info} ${GreenBG} 切换源-gh.api.99988866.xyz ${Font} \n ======== \n"
git remote set-url origin https://gh.api.99988866.xyz/https://github.com/lkeme/BiliHelper-personal.git
;;
*)
echo -e "\n ======== \n ${Info} ${GreenBG} 切换源-github.com ${Font} \n ======== \n"
git remote set-url origin https://github.com/lkeme/BiliHelper-personal.git
;;
echo -e "\n ======== \n ${Info} ${GreenBG} 切换源-github.com ${Font} \n ======== \n"
git remote set-url origin https://github.com/lkeme/BiliHelper-personal.git
;;
esac
# 拉取更新
@ -58,14 +58,37 @@ echo -e "\n ======== \n ${Info} ${GreenBG} 安装/更新 项目运行依赖 ${Fo
php composer.phar install
echo -e "\n \n \n \n"
# 判断类型
if [[ -f ${CONIFG_PATH} ]]; then
echo -e "\n ======== \n ${GreenBG} 正在使用外部配置文件 ${Font} \n ======== \n"
else
echo -e "${OK} ${GreenBG} 正在使用传入的环境变量进行用户配置。\n 如果需要配置更多选择项请通过挂载配置文件来传入。具体参考项目中的README。\n https://github.com/lkeme/BiliHelper-personal.git ${Font} \n ======== \n "
cp /app/profile/example /app/profile/user
sed -i ''"$(cat /app/profile/user/config/user.ini -n | grep "username = \"\"" | awk '{print $1}')"'c '"$(echo "username = \"${USER_NAME}\"")"'' ${CONIFG_PATH}
sed -i ''"$(cat /app/profile/user/config/user.ini -n | grep "password = \"\"" | awk '{print $1}')"'c '"$(echo "password = \"${USER_PASSWORD}\"")"'' ${CONIFG_PATH}
fi
# 版本切换
case ${VERSION} in
"1")
echo -e "\n ======== \n ${Info} ${GreenBG} 正在使用版本V1方案 ${Font} \n ======== \n"
# 判断类型
if [[ -f ${V1_CONIFG_PATH} ]]; then
echo -e "\n ======== \n ${GreenBG} 正在使用外部配置文件 ${Font} \n ======== \n"
else
echo -e "${OK} ${GreenBG} 正在使用传入的环境变量进行用户配置。\n 如果需要配置更多选择项请通过挂载配置文件来传入。具体参考项目中的README。\n https://github.com/lkeme/BiliHelper-personal.git ${Font} \n ======== \n "
cp /app/conf/user.ini.example /app/conf/user.ini
sed -i ''"$(cat /app/conf/user.ini -n | grep "username = \"\"" | awk '{print $1}')"'c '"$(echo "username = \"${USER_NAME}\"")"'' ${V1_CONIFG_PATH}
sed -i ''"$(cat /app/conf/user.ini -n | grep "password = \"\"" | awk '{print $1}')"'c '"$(echo "password = \"${USER_PASSWORD}\"")"'' ${V1_CONIFG_PATH}
fi
php app.php m:a
php index.php
;;
"2")
echo -e "\n ======== \n ${Info} ${GreenBG} 正在使用版本V2方案 ${Font} \n ======== \n"
# 判断类型
if [[ -f ${V2_CONIFG_PATH} ]]; then
echo -e "\n ======== \n ${GreenBG} 正在使用外部配置文件 ${Font} \n ======== \n"
else
echo -e "${OK} ${GreenBG} 正在使用传入的环境变量进行用户配置。\n 如果需要配置更多选择项请通过挂载配置文件来传入。具体参考项目中的README。\n https://github.com/lkeme/BiliHelper-personal.git ${Font} \n ======== \n "
cp /app/profile/example /app/profile/user
sed -i ''"$(cat /app/profile/user/config/user.ini -n | grep "username = \"\"" | awk '{print $1}')"'c '"$(echo "username = \"${USER_NAME}\"")"'' ${V2_CONIFG_PATH}
sed -i ''"$(cat /app/profile/user/config/user.ini -n | grep "password = \"\"" | awk '{print $1}')"'c '"$(echo "password = \"${USER_PASSWORD}\"")"'' ${V2_CONIFG_PATH}
fi
php app.php m:a
;;
*)
echo -e "\n ======== \n ${Info} ${RedBG} 错误的版本方案选择 ${Font} \n ======== \n"
;;
esac

View File

@ -191,6 +191,13 @@ $ docker run -itd --rm -e USER_NAME=你的B站登录账号 -e USER_PASSWORD=你
$ docker run -itd --rm -v /path/to/your/confFilePath:/app/profile/user lkeme/bilihelper-personal
```
- 版本兼容
```shell script
$ -e VERSION=1 # 使用 版本 V1.x.x
$ -e MIRRORS=2 # 使用 版本 V2.x.x(默认)
```
- 使用github镜像加速
```shell script