Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
42 lines (42 loc) · 2.15 KB
/
Copy pathdocker-compose.yml
File metadata and controls
42 lines (42 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# AITokenPool — Docker Compose 一键部署(v0.7.33)
#
# 快速开始:
# export ATP_MASTER_KEY=$(openssl rand -hex 32) # 必填,见下方说明
# docker compose up -d --build
# 浏览器打开 http://localhost:8080/
#
# ⚠️ 生产环境必须设置 ATP_MASTER_KEY(32 字节 hex 主密钥):
# 生成:openssl rand -hex 32
# 注入:export ATP_MASTER_KEY=$(openssl rand -hex 32) && docker compose up -d
# 未设置时 compose 直接报错退出(本文件不提供默认值):错误的主密钥会让重启后
# 已加密的上游 key 全部不可解密(全量 503)。本地试用同样请先执行上面的 export。
#
# 统一数据目录(rant 2026-08-19T20:53:23):只挂载一个 /data 卷,
# config.toml(首次启动自动从内置示例复制)+ aitokenpool.db + logs/ + archive/ 全在 ./atp-data/ 下。
services:
aitokenpool:
build: .
image: aitokenpool:0.7.33
ports:
- "8080:8080"
volumes:
# 统一数据目录:config / db / logs / archive 全在这里(服务端 --data-dir /data)
- ./atp-data:/data
environment:
# 主密钥(32 字节 hex;env 优先于 config [server].master_key)
# 必填:未设置时 docker compose 报错并给出生成命令
- ATP_MASTER_KEY=${ATP_MASTER_KEY:?未设置 ATP_MASTER_KEY:请提供 32 字节 hex 主密钥(生成:openssl rand -hex 32,见文件顶部说明)}
# 统一数据目录(与 Dockerfile CMD --data-dir /data 一致)
- ATP_DATA_DIR=/data
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/healthz"]
interval: 10s
timeout: 3s
retries: 5
start_period: 10s
# 停机窗口(rant 2026-09-30T16:25:29):docker 先发 SIGTERM,应用随即停止接受新连接
# 并在 `DRAIN_LIMIT_SECS` 内把在途请求排完(src/main.rs);这个上限到了 docker 就会
# 用 SIGKILL 直接打死还没排完的进程。所以此处必须**大于**应用那边的排水上限 ——
# 两个数的关系由 `src/shutdown_gate.rs` 守着,改一个忘了另一个会当场变红。
stop_grace_period: 12s
restart: unless-stopped