docker配置

This commit is contained in:
ChuXun
2026-01-29 05:57:54 +08:00
parent 9e65266b7e
commit f81af19a0a
7 changed files with 282 additions and 10 deletions

View File

@@ -24,6 +24,7 @@
- Python 3.7+
- 服务器能访问外网
- SSH访问权限
- 可选Docker 20+ / Docker Compose v2
## 📦 项目文件说明
@@ -127,6 +128,45 @@ python3 monitor.py --test
cat .last_grade_content.txt
```
---
## 🐳 Docker 部署(推荐)
> 适合已有 Docker 环境的服务器(例如 docker.aizhangz.top
### 1) 准备文件(本地或服务器)
必需文件:
- `monitor.py`
- `requirements.txt`
- `Dockerfile`
- `docker-compose.yml`
- `config.ini`(⚠️ 敏感文件)
### 2) 在服务器上运行
```bash
# 进入项目目录
cd ~/grade_monitor
# 首次构建并启动
docker compose up -d --build
# 查看日志
docker logs -f gpa-monitor
```
### 3) 测试模式(可选)
```bash
docker compose run --rm gpa-monitor python /app/monitor.py --config /data/config.ini --test
```
### 4) 说明
- 运行日志和缓存文件会写入 `./data/`
- 配置文件通过 `./config.ini:/data/config.ini:ro` 挂载
## 🔧 设置后台运行
### 使用 systemd推荐生产环境