fix: Web Dockerfile — use cp -rL to dereference pnpm symlinks
Some checks failed
CI / Lint → Typecheck → Test → Build (22) (push) Failing after 15s
CI / E2E Tests (push) Has been skipped
Deploy / Build API Image (push) Failing after 20s
Deploy / Build Web Image (push) Failing after 10s
E2E Tests / Playwright E2E (push) Failing after 18s
Deploy / Smoke Test Production (push) Has been skipped
Deploy / Rollback Staging (push) Has been skipped
Deploy / Rollback Production (push) Has been skipped
Deploy / Build AI Services Image (push) Failing after 10s
Deploy / Deploy to Staging (push) Has been skipped
Deploy / Smoke Test Staging (push) Has been skipped
Deploy / Deploy to Production (push) Has been skipped

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) <noreply@anthropic.com>
This commit is contained in:
Ho Ngoc Hai
2026-04-14 01:26:15 +07:00
parent 4870ac9214
commit b2a908983a

View File

@@ -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