-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Samiya
committed
Mar 8, 2024
1 parent
e9beff2
commit ed10b44
Showing
4 changed files
with
49 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,27 @@ | ||
# 阶段一:构建阶段 | ||
FROM python:3.10 AS builder | ||
|
||
# 合并命令以减少层数,并安装时区数据,同时清理缓存和不再需要的文件 | ||
RUN apt-get update && \ | ||
apt-get install -y --no-install-recommends tzdata && \ | ||
ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \ | ||
echo Asia/Shanghai > /etc/timezone && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# 设置工作目录 | ||
WORKDIR /root/VintageVigil | ||
|
||
# 将依赖文件单独复制,以利用Docker缓存 | ||
COPY requirements.txt . | ||
# 将依赖文件单独复制到工作目录,以利用Docker缓存 | ||
COPY requirements.txt /root/VintageVigil/ | ||
|
||
# 安装Python依赖,并清理pip缓存 | ||
RUN pip install --no-cache-dir -r requirements.txt --target /root/dependencies | ||
RUN cd /root/VintageVigil && pip install --no-cache-dir -r requirements.txt --target /root/dependencies | ||
|
||
# 将代码复制到容器内 | ||
COPY . . | ||
COPY . /root/VintageVigil | ||
|
||
# 确保启动脚本具有执行权限 | ||
RUN chmod +x /root/VintageVigil/start.sh | ||
|
||
# 阶段二:运行阶段 | ||
FROM python:3.10-slim AS runner | ||
|
||
# 复制时区设置 | ||
COPY --from=builder /etc/localtime /etc/localtime | ||
COPY --from=builder /etc/timezone /etc/timezone | ||
|
||
# 安装运行时依赖,并清理APT缓存 | ||
RUN apt-get update && \ | ||
apt-get install -y --no-install-recommends jq curl && \ | ||
apt-get install -y --no-install-recommends jq curl tzdata && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# 设置工作目录 | ||
WORKDIR /root/VintageVigil | ||
|
||
# 从构建阶段复制已安装的依赖 | ||
# 从构建阶段复制已安装的依赖和项目文件 | ||
COPY --from=builder /root/dependencies /usr/local/lib/python3.10/site-packages | ||
|
||
# 从构建阶段复制项目文件 | ||
COPY --from=builder /root/VintageVigil . | ||
|
||
# 确保启动脚本具有执行权限 | ||
RUN chmod +x /root/VintageVigil/start.sh | ||
|
||
|
||
# 设置容器启动时执行的命令(根据你的需要选择一个) | ||
# 自动监控 | ||
# CMD ["bash", "./run_checker.sh"] | ||
|
||
# 在控制台不输出日志 | ||
# CMD ["sh", "-c", "python ./main.py > /dev/null 2>&1"] | ||
|
||
# 在控制台输出日志 | ||
# CMD ["python", "./main.py"] | ||
CMD ["sh", "-c", "./start.sh"] | ||
COPY --from=builder /root/VintageVigil /root/VintageVigil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,28 @@ | ||
version: '3.8' | ||
|
||
services: | ||
# Web 文件管理 | ||
dufs: | ||
image: sigoden/dufs | ||
container_name: dufs | ||
vintagevigil: | ||
image: samiya777/vintagevigil:alpine | ||
restart: unless-stopped | ||
environment: | ||
# 配置文件远程仓库路径(如果不填写,请自行映射config至容器内) | ||
- CONFIG_PATH=https://github.com/Samiya321/VintageUser/tree/main/路径 | ||
# 配置文件变化监控间隔(默认60) | ||
# - CHECK_INTERVAL=60 | ||
# 是否使用内置的Github Token来进行GitHub请求,否则每分钟只能请求60次/单个IP(默认是) | ||
# - USE_TOKEN=true | ||
- TZ=Asia/Shanghai | ||
working_dir: /root/VintageVigil | ||
command: sh -c "./start.sh" | ||
volumes: | ||
- /root/VintageUser:/data | ||
ports: | ||
- 5000:5000 | ||
stdin_open: true | ||
tty: true | ||
command: /data -A | ||
VintageVigil: | ||
image: samiya777/vintagevigil:latest | ||
container_name: vintagevigil | ||
restart: unless-stopped | ||
- /root/.env:/root/VintageVigil/.env | ||
logging: | ||
driver: json-file | ||
options: | ||
max-size: "20m" | ||
max-file: "3" | ||
volumes: | ||
- /root/VintageUser/.env:/root/VintageVigil/.env # 环境变量 | ||
- /root/VintageUser/user:/root/VintageVigil/user/user # 配置文件 | ||
max-size: 20m | ||
max-file: "3" | ||
networks: | ||
- vintagevigil | ||
|
||
networks: | ||
vintagevigil: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters