接近完善的代码,待生产环境测试。

This commit is contained in:
panjunlan
2026-02-21 15:00:11 +08:00
parent 7c95ccb2af
commit d462263b39
2 changed files with 51 additions and 0 deletions

View File

@@ -398,9 +398,60 @@ pip install -r requirements.txt
## 构建 Docker 镜像
### 安装 Docker
``` shell
sudo curl https://download.docker.com/linux/centos/docker-ce.repo -o /etc/yum.repos.d/docker.repo
sudo dnf install docker-ce -y && docker -v
sudo systemctl enable --now docker && systemctl status docker
```
### 下载并解压代码文件
``` shell
wget https://gitcode.junlan.site/junlan/RemoveWeeklyShapshot/archive/Dev.zip && unzip Dev.zip && cd removeweeklyshapshot/
```
### 构建 Dockerfile 文件
``` dockerfile
cat << 'EOF' > Dockerfile
FROM python:3.14.3-slim
# 切换目录
WORKDIR /removeweeklysnapshot/
# 复制代码
COPY ./ /removeweeklysnapshot/
# 安装必要的软件和 python 库
RUN apt-get update && apt-get install procps tzdata -y && pip install -r requirements.txt
# 配置时区
ENV TZ=Asia/Shanghai
RUN ln -fs /usr/share/zoneinfo/$TZ /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
# 容器内执行启动程序
CMD ["/removeweeklysnapshot/main.py"]
EOF
```
### 执行构建 Docker 镜像
``` shell
sudo docker build --no-cache -t removeweeklysnapshot .
```
### 构建 Compose 文件
``` yaml
services:
move_ix_file:
container_name: removeweeklysnapshot
image: removeweeklysnapshot
restart: always
stdin_open: true
tty: true
```
### 运行容器
``` shell
docker compose up -d
```

BIN
requirements.txt Normal file

Binary file not shown.