perf(cd): Web build 加速 — buildx registry cache + turbo cache mount
Some checks failed
CD Pipeline / build-and-deploy (push) Has been cancelled
Some checks failed
CD Pipeline / build-and-deploy (push) Has been cancelled
切換 docker buildx + type=registry cache (mode=max): - 比 inline cache 更可靠,deps/runner 層存入 Harbor web-cache:buildcache - 移除 BUILDKIT_INLINE_CACHE=1(不再需要) Dockerfile 補 /root/.cache/turbo mount: - Turborepo task hash 跨 build 生效,未變動 packages 直接跳過 - 配合既有 .next/cache mount,預期節省 1-2 min Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -198,15 +198,18 @@ jobs:
|
||||
# 2026-04-01 Claude Code: 改用 CACHE_BUST=git_sha 取代 --no-cache
|
||||
# - deps 層 (pnpm install) 仍可 cache → 節省 ~2-3 min
|
||||
# - COPY . . 以下由 CACHE_BUST 強制失效 → CSRF fix 等代碼變更正確進入 bundle
|
||||
# 2026-04-12 Claude Code: 切換 buildx + registry cache (mode=max)
|
||||
# - deps/runner 層存入 Harbor web-cache:buildcache,比 inline cache 更可靠
|
||||
# - Dockerfile 補 turbo cache mount,Turborepo task hash 跨 build 生效
|
||||
# - 預期節省 1-2 min(deps 層 + turbo 增量)
|
||||
- name: Build and Push Web
|
||||
env:
|
||||
DOCKER_BUILDKIT: "1"
|
||||
run: |
|
||||
docker build -f apps/web/Dockerfile \
|
||||
docker buildx build -f apps/web/Dockerfile \
|
||||
--build-arg NEXT_PUBLIC_API_URL=https://awoooi.wooo.work \
|
||||
--build-arg CACHE_BUST=${{ github.sha }} \
|
||||
--build-arg BUILDKIT_INLINE_CACHE=1 \
|
||||
--cache-from ${{ env.HARBOR }}/awoooi/web:latest \
|
||||
--cache-from type=registry,ref=${{ env.HARBOR }}/awoooi/web-cache:buildcache \
|
||||
--cache-to type=registry,ref=${{ env.HARBOR }}/awoooi/web-cache:buildcache,mode=max \
|
||||
--output type=docker \
|
||||
-t ${{ env.HARBOR }}/awoooi/web:${{ github.sha }} \
|
||||
-t ${{ env.HARBOR }}/awoooi/web:latest \
|
||||
.
|
||||
|
||||
@@ -47,7 +47,10 @@ ENV NEXT_TELEMETRY_DISABLED=1
|
||||
|
||||
# 2026-04-06 ogt: --mount=type=cache 持久化 .next/cache,跨 build 增量編譯
|
||||
# 只有變更的頁面重新編譯,未變更頁面直接用 cache → 節省 3-4 min
|
||||
# 2026-04-12 Claude Code: 補 turbo cache mount,Turborepo task hash 跨 build 生效
|
||||
# /root/.cache/turbo 存放 turbo 的 task 輸出快取,避免每次重跑未變動的 packages
|
||||
RUN --mount=type=cache,target=/app/apps/web/.next/cache \
|
||||
--mount=type=cache,target=/root/.cache/turbo \
|
||||
pnpm turbo build --filter=@awoooi/web
|
||||
|
||||
FROM base AS runner
|
||||
|
||||
Reference in New Issue
Block a user