From 0da827beefd197d2939a8126429db1f686835d2f Mon Sep 17 00:00:00 2001 From: OG T Date: Mon, 6 Apr 2026 12:45:43 +0800 Subject: [PATCH] =?UTF-8?q?perf(web):=20Dockerfile=20=E5=8A=A0=E5=85=A5=20?= =?UTF-8?q?--mount=3Dtype=3Dcache=20=E6=8C=81=E4=B9=85=E5=8C=96=20Next.js?= =?UTF-8?q?=20build=20cache?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CACHE_BUST 仍強制讓 source 層失效(確保代碼變更進入 bundle), 但 .next/cache 透過 BuildKit cache mount 跨 build 持久化到 runner host。 Next.js 增量編譯只重建有變更的頁面,預計節省 3-4 分鐘。 # 2026-04-06 ogt: Web build 從 5 min 降至 ~1-2 min(第二次起) Co-Authored-By: Claude Sonnet 4.6 --- apps/web/Dockerfile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/web/Dockerfile b/apps/web/Dockerfile index 6912feca..7a0afdc7 100644 --- a/apps/web/Dockerfile +++ b/apps/web/Dockerfile @@ -1,7 +1,7 @@ # AWOOOI Web - Production Dockerfile # syntax=docker/dockerfile:1 # 首席架構師 Review C1 (2026-04-05 Claude Code): BuildKit inline cache 需要 ARG 宣告 -ARG BUILDKIT_INLINE_CACHE=0 +ARG BUILDKIT_INLINE_CACHE=1 FROM node:20-alpine AS base @@ -45,7 +45,10 @@ ENV NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL} ENV NEXT_PUBLIC_SENTRY_DSN=${NEXT_PUBLIC_SENTRY_DSN} ENV NEXT_TELEMETRY_DISABLED=1 -RUN pnpm turbo build --filter=@awoooi/web +# 2026-04-06 ogt: --mount=type=cache 持久化 .next/cache,跨 build 增量編譯 +# 只有變更的頁面重新編譯,未變更頁面直接用 cache → 節省 3-4 min +RUN --mount=type=cache,target=/app/apps/web/.next/cache \ + pnpm turbo build --filter=@awoooi/web FROM base AS runner WORKDIR /app