From 3c7d6eb301d62c8feba27977a53ff26aecd1a7db Mon Sep 17 00:00:00 2001 From: chenhang Date: Thu, 9 Jul 2026 16:13:38 +0800 Subject: [PATCH] build(docker): reduce runtime image size --- Dockerfile | 6 ------ next.config.ts | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3f35e541..2da0c8fc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,11 +16,6 @@ COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./ RUN --mount=type=cache,id=cozsweet-pnpm-store,target=/pnpm/store,sharing=locked \ pnpm install --frozen-lockfile --prefer-offline -FROM base AS prod-deps -COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./ -RUN --mount=type=cache,id=cozsweet-pnpm-store,target=/pnpm/store,sharing=locked \ - pnpm install --prod --frozen-lockfile --prefer-offline - FROM base AS builder ARG NEXT_ENV_FILE=.env.local ENV CI=true @@ -49,7 +44,6 @@ RUN addgroup --system --gid 1001 nodejs \ COPY --from=builder /app/public ./public COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static -COPY --from=prod-deps --chown=nextjs:nodejs /app/node_modules ./node_modules COPY --from=builder --chown=nextjs:nodejs /app/src/app/sw.ts ./src/app/sw.ts USER nextjs diff --git a/next.config.ts b/next.config.ts index 9ac37e24..b427f648 100644 --- a/next.config.ts +++ b/next.config.ts @@ -9,7 +9,7 @@ import { withSerwist } from "@serwist/turbopack"; * * 容器化部署模型:`output: "standalone"` + Docker Compose。 * - `pnpm build` 产出 .next/standalone、.next/static、public。 - * - Dockerfile 运行 `node server.js`,并保留生产依赖以支持 Serwist 运行时生成 SW。 + * - Dockerfile 运行 `node server.js`,仅复制 standalone traced runtime 依赖。 */ const nextConfig: NextConfig = { output: "standalone",