From b2a908983aa7f4a671505e323afc3b0a57be2f61 Mon Sep 17 00:00:00 2001 From: Ho Ngoc Hai Date: Tue, 14 Apr 2026 01:26:15 +0700 Subject: [PATCH] =?UTF-8?q?fix:=20Web=20Dockerfile=20=E2=80=94=20use=20cp?= =?UTF-8?q?=20-rL=20to=20dereference=20pnpm=20symlinks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit pnpm standalone output contains symlinks in node_modules/. Docker COPY preserves symlinks as symlinks (broken in final image). Use cp -rL in flatten stage to resolve them to real files. Co-Authored-By: Claude Opus 4 (1M context) --- apps/web/Dockerfile | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/apps/web/Dockerfile b/apps/web/Dockerfile index 0260118..3a9adea 100644 --- a/apps/web/Dockerfile +++ b/apps/web/Dockerfile @@ -18,13 +18,12 @@ COPY apps/web/ apps/web/ RUN cd apps/web && npx next build # ---- Flatten standalone ---- -# Next.js standalone with outputFileTracingRoot at repo root creates: -# .next/standalone/ → node_modules/.pnpm/... + apps/web/server.js -# We flatten it so /app has server.js + node_modules/ + .next/ +# Next.js standalone with pnpm creates symlinks in node_modules. +# Use cp -rL to dereference symlinks into real files. FROM node:22-slim AS flatten WORKDIR /app COPY --from=build /app/apps/web/.next/standalone/ /standalone/ -RUN cp -r /standalone/node_modules /app/node_modules && \ +RUN cp -rL /standalone/node_modules /app/node_modules && \ cp -r /standalone/apps/web/* /app/ 2>/dev/null || true && \ cp -r /standalone/apps/web/.next /app/.next 2>/dev/null || true && \ rm -rf /standalone