deploy(compose): app healthcheck + 优雅停 + 日志策略 + README 部署章节

- Dockerfile:alpine 安装 wget;加 HEALTHCHECK(/v1/health 探测,
  interval 15s、start_period 20s、retries 3)
- docker-compose.yml app:
  · stop_grace_period 30s(配合 fiber ShutdownWithContext 10s
    + cron 任务收尾,避免 SIGKILL 截断在途请求)
  · restart unless-stopped
  · json-file logging:单文件 50MB、保留 5 个滚动文件
  · 业务日志卷 ./logs:/app/logs
- docker-compose.yml postgres:同样配 restart + logging
- logs/ 目录用 .gitkeep 保留;.gitignore 加 logs/* + !logs/.gitkeep
- README 新增'一键部署(docker compose)'整章:3 步上线、启动顺序图、
  healthcheck 说明、优雅停机、日志、回填历史、生产 checklist

所有 12 条守卫保持无输出;build / vet 干净。
This commit is contained in:
dela
2026-05-24 21:01:45 +08:00
parent 16f7f00d7b
commit ea22d06dab
5 changed files with 114 additions and 1 deletions

View File

@@ -17,6 +17,12 @@ services:
timeout: 3s
retries: 10
start_period: 10s
restart: unless-stopped
logging:
driver: json-file
options:
max-size: "50m"
max-file: "5"
# init container跑完 migration 立即退出。
# 由 app 依赖它 service_completed_successfully保证表存在再启动 app。
@@ -58,6 +64,16 @@ services:
NO_PROXY: ${NO_PROXY:-}
volumes:
- ./config:/app/config:ro
- ./logs:/app/logs
# SIGTERM → 等 app 内置 10s graceful shutdownfiber.ShutdownWithContext
# + cron 任务结束的缓冲 = 30s。超时后 docker 发 SIGKILL。
stop_grace_period: 30s
restart: unless-stopped
logging:
driver: json-file
options:
max-size: "50m"
max-file: "5"
volumes:
hermes_pg_data: