fix: Web Dockerfile — rebuild pnpm symlinks in flatten stage
Some checks failed
CI / Lint → Typecheck → Test → Build (22) (push) Failing after 14s
CI / E2E Tests (push) Has been skipped
Deploy / Build Web Image (push) Failing after 18s
Deploy / Build AI Services Image (push) Failing after 12s
E2E Tests / Playwright E2E (push) Failing after 12s
Deploy / Build API Image (push) Failing after 14m0s
Deploy / Deploy to Staging (push) Has been cancelled
Deploy / Smoke Test Staging (push) Has been cancelled
Deploy / Rollback Staging (push) Has been cancelled
Deploy / Deploy to Production (push) Has been cancelled
Deploy / Smoke Test Production (push) Has been cancelled
Deploy / Rollback Production (push) Has been cancelled
Some checks failed
CI / Lint → Typecheck → Test → Build (22) (push) Failing after 14s
CI / E2E Tests (push) Has been skipped
Deploy / Build Web Image (push) Failing after 18s
Deploy / Build AI Services Image (push) Failing after 12s
E2E Tests / Playwright E2E (push) Failing after 12s
Deploy / Build API Image (push) Failing after 14m0s
Deploy / Deploy to Staging (push) Has been cancelled
Deploy / Smoke Test Staging (push) Has been cancelled
Deploy / Rollback Staging (push) Has been cancelled
Deploy / Deploy to Production (push) Has been cancelled
Deploy / Smoke Test Production (push) Has been cancelled
Deploy / Rollback Production (push) Has been cancelled
pnpm standalone output has top-level symlinks pointing outside the dir. Copy .pnpm store (real files), then find+link each package correctly. Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -18,12 +18,29 @@ COPY apps/web/ apps/web/
|
|||||||
RUN cd apps/web && npx next build
|
RUN cd apps/web && npx next build
|
||||||
|
|
||||||
# ---- Flatten standalone ----
|
# ---- Flatten standalone ----
|
||||||
# Next.js standalone with pnpm creates symlinks in node_modules.
|
# Next.js standalone with pnpm creates symlinks that point outside the standalone dir.
|
||||||
# Use cp -rL to dereference symlinks into real files.
|
# We copy .pnpm (real files), then fix symlinks to point to local .pnpm store.
|
||||||
FROM node:22-slim AS flatten
|
FROM node:22-slim AS flatten
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=build /app/apps/web/.next/standalone/ /standalone/
|
COPY --from=build /app/apps/web/.next/standalone/ /standalone/
|
||||||
RUN cp -rL /standalone/node_modules /app/node_modules && \
|
|
||||||
|
# Copy .pnpm store (real files) and rebuild top-level symlinks
|
||||||
|
RUN cp -r /standalone/node_modules/.pnpm /app/node_modules/.pnpm 2>/dev/null || true && \
|
||||||
|
# For each broken symlink in standalone/node_modules, find the package in .pnpm and link it
|
||||||
|
for link in /standalone/node_modules/*; do \
|
||||||
|
name=$(basename "$link"); \
|
||||||
|
[ "$name" = ".pnpm" ] && continue; \
|
||||||
|
if [ -L "$link" ]; then \
|
||||||
|
# Find the real package dir in .pnpm
|
||||||
|
real=$(find /app/node_modules/.pnpm -path "*/$name/package.json" -not -path "*/node_modules/.pnpm/*" 2>/dev/null | head -1); \
|
||||||
|
if [ -n "$real" ]; then \
|
||||||
|
ln -sf "$(dirname "$real")" "/app/node_modules/$name"; \
|
||||||
|
fi; \
|
||||||
|
elif [ -d "$link" ]; then \
|
||||||
|
cp -r "$link" "/app/node_modules/$name"; \
|
||||||
|
fi; \
|
||||||
|
done && \
|
||||||
|
# Copy server files from apps/web
|
||||||
cp -r /standalone/apps/web/* /app/ 2>/dev/null || true && \
|
cp -r /standalone/apps/web/* /app/ 2>/dev/null || true && \
|
||||||
cp -r /standalone/apps/web/.next /app/.next 2>/dev/null || true && \
|
cp -r /standalone/apps/web/.next /app/.next 2>/dev/null || true && \
|
||||||
rm -rf /standalone
|
rm -rf /standalone
|
||||||
|
|||||||
Reference in New Issue
Block a user