ci: harden deploy timeout and compose pull retry

This commit is contained in:
chengkai3
2026-04-12 21:19:24 +08:00
parent b88b775f84
commit 2c854cc6af
3 changed files with 40 additions and 1 deletions
+16
View File
@@ -107,3 +107,19 @@
- `docker compose build api --build-arg PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple --build-arg PIP_DEFAULT_TIMEOUT=600 --build-arg PIP_RETRIES=30`
- `docker compose up -d api` 后状态为 `Up ... (healthy)`
- `curl http://127.0.0.1:8000/health` 返回 `{"status":"ok","service":"fquiz-api","version":"0.1.0"}`
## 追加修复(GitHub 发布 Run Command Timeout
- 触发问题:
- 发布阶段日志持续停留在 `docker compose pull` 的 layer 下载进度。
- `appleboy/ssh-action` 最终报错:`Run Command Timeout`,作业退出码 `1`
- 根因:
- 远端拉取镜像速度慢时,SSH Action 的命令执行超时先触发,未等到 `docker compose pull` 自然完成。
- 处理:
- 更新 `.github/workflows/main.yml` 部署步骤:
-`appleboy/ssh-action` 增加 `timeout: 120s``command_timeout: 45m`
- 脚本内新增 `DOCKER_CLIENT_TIMEOUT=600``COMPOSE_HTTP_TIMEOUT=600` 默认值。
- 新增 `pull_with_retry`(最多 3 次)包装 `docker compose pull`,网络抖动时自动重试。
- 验证建议:
- 推送触发 `main` 发布,观察部署日志不再在固定时长点报 `Run Command Timeout`
- 远端 `docker compose ps` 应显示 `db/api/web` 均为 `Up`(或 `healthy`)。