Skip to content

Commit 4eae315

Browse files
committed
feat(deploy): add docker-compose with data persistence and .env support
Add docker-compose.yml with named volumes for cache/result/log, healthcheck, and .env file support. Include .env.example template and update README with Docker deployment instructions.
1 parent ccb7b73 commit 4eae315

3 files changed

Lines changed: 110 additions & 6 deletions

File tree

.env.example

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# AutoPCR Docker Configuration
2+
# Copy this file to .env and modify as needed
3+
# cp .env.example .env
4+
5+
# ---- Server Settings ----
6+
7+
# HTTP server bind address (0.0.0.0 = all interfaces)
8+
AUTOPCR_SERVER_HOST=0.0.0.0
9+
10+
# HTTP server port
11+
AUTOPCR_SERVER_PORT=13200
12+
13+
# Enable debug logging (true/false)
14+
AUTOPCR_SERVER_DEBUG_LOG=false
15+
16+
# Allow new user registration (true/false)
17+
AUTOPCR_SERVER_ALLOW_REGISTER=true
18+
19+
# Superuser QQ number (has admin privileges, leave empty to disable)
20+
AUTOPCR_SERVER_SUPERUSER=
21+
22+
# ---- Public Access (for QQ bot message links) ----
23+
24+
# Public IP or domain for QQ bot to send access links
25+
# e.g., "example.com" or "1.2.3.4:13200"
26+
# Leave empty to auto-detect
27+
AUTOPCR_PUBLIC_ADDRESS=
28+
29+
# Use HTTPS for public access links (true/false)
30+
AUTOPCR_USE_HTTPS=false
31+
32+
# ---- Docker Settings ----
33+
34+
# Host port to map (change if 13200 is occupied)
35+
HOST_PORT=13200
36+
37+
# Container timezone
38+
TZ=Asia/Shanghai
39+
40+
# Restart policy: no | always | on-failure | unless-stopped
41+
RESTART_POLICY=unless-stopped

README.md

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,43 @@ python3 _httpserver_test.py
2525

2626
渠道服需要自抓`uid``access_key`,作为用户名和密码。
2727

28+
## Docker 部署
29+
30+
```bash
31+
# 1. 复制环境变量模板并按需修改
32+
cp .env.example .env
33+
34+
# 2. 一键启动
35+
docker compose up -d
36+
37+
# 查看日志
38+
docker compose logs -f
39+
40+
# 停止服务(数据不会丢失)
41+
docker compose down
42+
```
43+
44+
数据持久化通过 Docker named volumes 实现,以下目录会被持久化保存:
45+
46+
| 卷名 | 容器路径 | 说明 |
47+
|------|---------|------|
48+
| `autopcr_cache` | `/app/cache` | 用户账号配置、游戏数据库、session |
49+
| `autopcr_result` | `/app/result` | 任务执行结果 |
50+
| `autopcr_log` | `/app/log` | 应用日志 |
51+
2852
## 配置
2953

30-
| 环境变量 | 描述 | 默认值(留空则表示必填) |
31-
|-------------------------------|---------------|------------------|
32-
| AUTOPCR_SERVER_PORT | 自定义服务器启动端口 | 13200 |
33-
| AUTOPCR_SERVER_DEBUG_LOG | 是否输出 Debug 日志 | False |
34-
| AUTOPCR_SERVER_ALLOW_REGISTER | 是否允许注册 | True |
35-
| AUTOPCR_SERVER_SUPERUSER | 设置无条件拥有管理员的用户 | (可选,设置为登录使用的 QQ) |
54+
所有配置均可通过环境变量控制,Docker 部署时在 `.env` 文件中设置即可,参见 `.env.example`
55+
56+
| 环境变量 | 描述 | 默认值 |
57+
|---------|------|--------|
58+
| AUTOPCR_SERVER_HOST | 服务器绑定地址 | 0.0.0.0 |
59+
| AUTOPCR_SERVER_PORT | 服务器启动端口 | 13200 |
60+
| AUTOPCR_SERVER_DEBUG_LOG | 是否输出 Debug 日志 | False |
61+
| AUTOPCR_SERVER_ALLOW_REGISTER | 是否允许注册 | True |
62+
| AUTOPCR_SERVER_SUPERUSER | 设置无条件拥有管理员的用户 | (可选,设置为登录使用的 QQ) |
63+
| AUTOPCR_PUBLIC_ADDRESS | QQ bot 发送的公网访问地址 | (可选,留空自动检测) |
64+
| AUTOPCR_USE_HTTPS | 公网访问链接是否使用 HTTPS | False |
3665

3766
## Credits
3867
- aiorequests 来自 [HoshinoBot](https://github.com/Ice-Cirno/HoshinoBot)

docker-compose.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
services:
2+
autopcr:
3+
image: ghcr.io/cc004/autopcr:latest
4+
container_name: autopcr
5+
restart: ${RESTART_POLICY:-unless-stopped}
6+
ports:
7+
- "${HOST_PORT:-13200}:${AUTOPCR_SERVER_PORT:-13200}"
8+
environment:
9+
- AUTOPCR_SERVER_HOST=${AUTOPCR_SERVER_HOST:-0.0.0.0}
10+
- AUTOPCR_SERVER_PORT=${AUTOPCR_SERVER_PORT:-13200}
11+
- AUTOPCR_SERVER_DEBUG_LOG=${AUTOPCR_SERVER_DEBUG_LOG:-false}
12+
- AUTOPCR_SERVER_ALLOW_REGISTER=${AUTOPCR_SERVER_ALLOW_REGISTER:-true}
13+
- AUTOPCR_SERVER_SUPERUSER=${AUTOPCR_SERVER_SUPERUSER:-}
14+
- AUTOPCR_PUBLIC_ADDRESS=${AUTOPCR_PUBLIC_ADDRESS:-}
15+
- AUTOPCR_USE_HTTPS=${AUTOPCR_USE_HTTPS:-false}
16+
- TZ=${TZ:-Asia/Shanghai}
17+
volumes:
18+
- autopcr_cache:/app/cache
19+
- autopcr_result:/app/result
20+
- autopcr_log:/app/log
21+
healthcheck:
22+
test: ["CMD", "python3", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:${AUTOPCR_SERVER_PORT:-13200}/daily/login')"]
23+
interval: 30s
24+
timeout: 10s
25+
retries: 3
26+
start_period: 30s
27+
28+
volumes:
29+
autopcr_cache:
30+
driver: local
31+
autopcr_result:
32+
driver: local
33+
autopcr_log:
34+
driver: local

0 commit comments

Comments
 (0)