feat(ci): 镜像并行构建 - 三镜像并行构建,构建时间从17min压缩到8-10min #314

Merged
xiaoxia merged 2 commits from feat/ci-parallel-build into develop 2026-07-14 15:08:43 +08:00
Owner

改动说明

核心改造

将 Staging 和 Production 的镜像构建从「单Job串行构建3个镜像」改为「3个并行Job各构建1个镜像」。

Staging构建改造:

  • 新增 build-staging-api / build-staging-worker / build-staging-web 三个并行Job
  • 每个Job独立checkout代码 + docker login + buildx构建 + 直推Registry
  • deploy-staging 不再构建镜像,只负责:pull镜像 → tag为:staging → push → smoke test → 通知
  • 依赖关系:staging-e2e / staging-api-tests 继续依赖 deploy-staging(不变)

Production构建改造:

  • 新增 build-production-api / build-production-worker / build-production-web 三个并行Job
  • deploy-production 的依赖从 build-production-runtime-images 改为3个build job

优化点

  1. 构建并行化:3镜像同时构建,总耗时 = 最慢的那个(web镜像8min),从17min压缩到~8-10min
  2. buildx --push直推:省去 --load 到本地 → tag → push 的额外流程
  3. Registry Cache 按镜像独立:api/worker/web各有独立的cache镜像,互不干扰
  4. 缓存策略:develop/main分支写回缓存,feature分支只读,防止污染

资源影响

  • 需要同时占用3个saas Runner进行构建(目前9个在线,够用)
  • 总构建时长缩短,但总Runner耗时基本不变(3个Job各跑8min ≈ 1个Job跑17min)
## 改动说明 ### 核心改造 将 Staging 和 Production 的镜像构建从「单Job串行构建3个镜像」改为「3个并行Job各构建1个镜像」。 **Staging构建改造:** - 新增 `build-staging-api` / `build-staging-worker` / `build-staging-web` 三个并行Job - 每个Job独立checkout代码 + docker login + buildx构建 + 直推Registry - `deploy-staging` 不再构建镜像,只负责:pull镜像 → tag为:staging → push → smoke test → 通知 - 依赖关系:staging-e2e / staging-api-tests 继续依赖 deploy-staging(不变) **Production构建改造:** - 新增 `build-production-api` / `build-production-worker` / `build-production-web` 三个并行Job - `deploy-production` 的依赖从 `build-production-runtime-images` 改为3个build job ### 优化点 1. **构建并行化**:3镜像同时构建,总耗时 = 最慢的那个(web镜像~8min),从~17min压缩到~8-10min 2. **buildx --push直推**:省去 --load 到本地 → tag → push 的额外流程 3. **Registry Cache 按镜像独立**:api/worker/web各有独立的cache镜像,互不干扰 4. **缓存策略**:develop/main分支写回缓存,feature分支只读,防止污染 ### 资源影响 - 需要同时占用3个saas Runner进行构建(目前9个在线,够用) - 总构建时长缩短,但总Runner耗时基本不变(3个Job各跑8min ≈ 1个Job跑17min)
xiaoxia added 2 commits 2026-07-14 15:06:39 +08:00
fix: update runner labels to match new scheme [host, ci-check] / [host, build-only]
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Successful in 42s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 1m23s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 1m55s
CI/CD Pipeline / Build Staging Worker Image (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 / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / Integration Tests (pull_request) Successful in 1m20s
c34c1634fc
xiaoxia force-pushed feat/ci-parallel-build from 932b43a689 to c34c1634fc 2026-07-14 15:06:39 +08:00 Compare
xiaoxia merged commit 79b82978d8 into develop 2026-07-14 15:08:43 +08:00
Sign in to join this conversation.