fix(staging): use stable :dev tag for containers to enable Watchtower auto-update #2121

Merged
auto-approve-bot merged 2 commits from fix/watchtower-stable-tag into develop 2026-10-01 12:20:07 +08:00
Owner

问题

Watchtower 无法自动更新 staging 容器,因为容器使用 commit SHA tag(如 7fd9c0cf...)启动。
Watchtower 只能检测同一个 tag 的 digest 变化,commit SHA tag 每次构建都不同,所以 Watchtower 永远发现不了更新。

修复

  1. 在 ci_staging_deploy.sh 中,pull 完 commit SHA 镜像后,docker tag 为 :dev
  2. 容器启动时使用 :dev tag(API/Web/Worker 统一)
  3. Migration(alembic)仍使用 commit SHA tag(--rm 模式,不需要 Watchtower 监控)

效果

  • Watchtower 每 5 分钟检查 :dev tag 的 digest 变化
  • 每次 CI 部署后,:dev tag 指向新镜像,Watchtower 自动拉取并重启容器
  • 不影响 CI 精确版本追踪(commit SHA 镜像仍然存在)

关于 Retag skipped

Retag skipped 步骤被跳过是正常行为——它只在 Build 被跳过时才运行(frontend-only/backend-only变更)。
当 Build 实际执行时,Retag 不需要运行,因为 Build 已经推送了所有需要的 tag(包括 :dev)。
真正的问题是部署脚本用 commit SHA tag 启动容器,而不是 :dev tag。

关于 Docker ACR 凭证

CI 部署脚本中已包含 retry_docker_login 函数,每次部署都会自动登录 ACR。
服务器迁移后需要确保 /root/.docker/config.json 中有有效的 ACR 凭证。
本次已修复 Watchtower 容器的 config.json 挂载。

## 问题 Watchtower 无法自动更新 staging 容器,因为容器使用 commit SHA tag(如 `7fd9c0cf...`)启动。 Watchtower 只能检测同一个 tag 的 digest 变化,commit SHA tag 每次构建都不同,所以 Watchtower 永远发现不了更新。 ## 修复 1. 在 `ci_staging_deploy.sh` 中,pull 完 commit SHA 镜像后,`docker tag` 为 `:dev` 2. 容器启动时使用 `:dev` tag(API/Web/Worker 统一) 3. Migration(alembic)仍使用 commit SHA tag(`--rm` 模式,不需要 Watchtower 监控) ## 效果 - Watchtower 每 5 分钟检查 `:dev` tag 的 digest 变化 - 每次 CI 部署后,`:dev` tag 指向新镜像,Watchtower 自动拉取并重启容器 - 不影响 CI 精确版本追踪(commit SHA 镜像仍然存在) ## 关于 Retag skipped `Retag skipped` 步骤被跳过是**正常行为**——它只在 Build 被跳过时才运行(frontend-only/backend-only变更)。 当 Build 实际执行时,Retag 不需要运行,因为 Build 已经推送了所有需要的 tag(包括 `:dev`)。 真正的问题是部署脚本用 commit SHA tag 启动容器,而不是 `:dev` tag。 ## 关于 Docker ACR 凭证 CI 部署脚本中已包含 `retry_docker_login` 函数,每次部署都会自动登录 ACR。 服务器迁移后需要确保 `/root/.docker/config.json` 中有有效的 ACR 凭证。 本次已修复 Watchtower 容器的 config.json 挂载。
xiaoxia added 1 commit 2026-10-01 12:03:22 +08:00
fix(staging): use stable :dev tag for containers to enable Watchtower auto-update
CI/CD Pipeline / Check push changed paths (pull_request) Has been skipped
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 7s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 6s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 58s
CI/CD Pipeline / PR Build Web Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 47s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 2m2s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m12s
CI/CD Pipeline / Build Production API Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Web Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Deploy Production (pull_request) Has been cancelled
CI/CD Pipeline / Production Browser E2E (pull_request) Has been cancelled
CI/CD Pipeline / Canary Release to Production (pull_request) Has been cancelled
CI/CD Pipeline / CI Gate (pull_request) Has been cancelled
CI/CD Pipeline / Unit Tests (pull_request) Has been cancelled
CI/CD Pipeline / Integration Tests (pull_request) Has been cancelled
CI/CD Pipeline / Validate - Style (pull_request) Has been cancelled
CI/CD Pipeline / Validate - Security (pull_request) Has been cancelled
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Has been cancelled
AI Code Review / AI Code Review (pull_request) Has been cancelled
PR Automation / Auto Merge on CI Green + Approved (pull_request) Has been cancelled
ebc851b12b
- After pulling commit SHA images, tag them as :dev
- Start API/Web/Worker containers using :dev tag instead of commit SHA
- Watchtower can now detect digest changes on the stable :dev tag
- Migration (alembic) still uses commit SHA tag for reliability
- Fixes: Watchtower unable to auto-update because commit SHA tags are immutable

🚀 预览环境已部署

项目 详情
PR号 #2121
预览链接 https://pr-2121.preview.xiaoxiajianji.com
API环境 staging

💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。

🔄 每次提交新代码后预览环境会自动更新。

🗑️ PR 关闭或合并后,预览环境会自动清理。

🚀 **预览环境已部署** | 项目 | 详情 | |------|------| | PR号 | #2121 | | 预览链接 | [https://pr-2121.preview.xiaoxiajianji.com](https://pr-2121.preview.xiaoxiajianji.com) | | API环境 | staging | > 💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。 > > 🔄 每次提交新代码后预览环境会自动更新。 > > 🗑️ PR 关闭或合并后,预览环境会自动清理。
xiaoxia added 1 commit 2026-10-01 12:08:18 +08:00
docs: add Docker credential and Watchtower configuration to DEPLOYMENT.md
CI/CD Pipeline / Check push changed paths (pull_request) Has been skipped
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 2s
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 3s
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / PR Build Web Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 44s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 57s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 1m58s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m20s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 4m19s
CI/CD Pipeline / Validate - Style (pull_request) Successful in 4m59s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Successful in 4m57s
AI Code Review / AI Code Review (pull_request) Successful in 7m8s
CI/CD Pipeline / Validate - Security (pull_request) Successful in 10m30s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 10m54s
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Canary Release to Production (pull_request) Has been skipped
CI/CD Pipeline / CI Gate (pull_request) Successful in 1s
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 8m24s
ACR Cleanup / ACR Image Cleanup (pull_request_target) Successful in 31s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 4m49s
eaec032f5c
- Document staging server docker credential setup for ACR and Gitea registry
- Add Watchtower container configuration details
- Document image tag strategy (commit SHA + dev stable tag)
- Include server migration recovery steps
auto-approve-bot merged commit 4ed906e5fa into develop 2026-10-01 12:20:07 +08:00
auto-approve-bot deleted branch fix/watchtower-stable-tag 2026-10-01 12:20:09 +08:00

🗑️ 预览环境已清理

PR #2121 已关闭或合并,对应的预览环境已被清理。

如有需要,可以重新打开 PR 来重新生成预览环境。

🗑️ **预览环境已清理** PR #2121 已关闭或合并,对应的预览环境已被清理。 > 如有需要,可以重新打开 PR 来重新生成预览环境。
Sign in to join this conversation.