Skip to content

Commit

Permalink
feat: 为docker镜像添加环境变量的配置文件方式
Browse files Browse the repository at this point in the history
  • Loading branch information
mcoo committed Jun 26, 2022
1 parent 6f21352 commit a067234
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ LABEL MAINTAINER enjoy<[email protected]>

WORKDIR /apps
COPY --from=build /apps/opqbot/ /apps/

COPY ./entrypoint.sh /apps/entrypoint.sh
# 设置时区
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone

Expand All @@ -25,7 +25,9 @@ ENV LANG C.UTF-8

EXPOSE 8888

RUN mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2
RUN mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2 && chmod +x /apps/entrypoint.sh

VOLUME [ "/apps/UsersConf" ]

# 开RUN
ENTRYPOINT ["/apps/OPQBot"]
ENTRYPOINT ["/apps/entrypoint.sh"]
17 changes: 17 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh
if [[ "$token" == "" ]] ; then
if [[ "$(awk -F= '$1 ~ /^Token.*$/ {gsub(/^\s*|\s*$|"/, "",$2);print $2}' CoreConf.conf)" != "" ]] ; then
echo "使用配置文件中的Token运行"
else
echo "你Token呢?认真读文档啊喂 文档链接: https://github.com/opq-osc/OPQ/wiki/%E9%80%9A%E8%BF%87-Docker-%E5%AE%89%E8%A3%85 "
exit 1
fi
else
sed -i "s/Token\s*=.*/Token = \"${token}\"/g" CoreConf.conf
fi
if [[ "$port" != "" ]] ; then
sed -i "s/Port\s*=.*/Port = \"${port}\"/g" CoreConf.conf
echo "已经将机器人地址设置为$port"
fi
echo "开始执行OPQBot"
/apps/OPQBot

0 comments on commit a067234

Please sign in to comment.