From 4418d60c2b819fb80225b22bd0872eb088757aa6 Mon Sep 17 00:00:00 2001 From: Ho Ngoc Hai Date: Tue, 14 Apr 2026 00:19:48 +0700 Subject: [PATCH] =?UTF-8?q?fix:=20Web=20standalone=20=E2=80=94=20set=20out?= =?UTF-8?q?putFileTracingRoot=20to=20repo=20root?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In monorepo, Next.js standalone creates symlinks instead of real files. Setting outputFileTracingRoot to repo root produces self-contained output. Dockerfile updated to copy from correct standalone structure. Co-Authored-By: Claude Opus 4 (1M context) --- apps/web/Dockerfile | 12 ++++++++---- apps/web/next.config.js | 2 ++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/apps/web/Dockerfile b/apps/web/Dockerfile index 5f1d607..2916c4b 100644 --- a/apps/web/Dockerfile +++ b/apps/web/Dockerfile @@ -28,10 +28,14 @@ ENV HOSTNAME=0.0.0.0 ENV PORT=3000 # Copy Next.js standalone output -# In monorepo with `cd apps/web && next build`, standalone contains: -# .next/standalone/ → root with server.js + node_modules/ + package.json -RUN mkdir -p ./public -COPY --from=build --chown=node:node /app/apps/web/.next/standalone ./ +# With outputFileTracingRoot=repo_root, standalone structure is: +# .next/standalone/node_modules/ → real deps (not symlinks) +# .next/standalone/apps/web/ → server.js, .next/, package.json +RUN mkdir -p ./public ./.next/static +COPY --from=build --chown=node:node /app/apps/web/.next/standalone/node_modules ./node_modules +COPY --from=build --chown=node:node /app/apps/web/.next/standalone/apps/web/server.js ./server.js +COPY --from=build --chown=node:node /app/apps/web/.next/standalone/apps/web/package.json ./package.json +COPY --from=build --chown=node:node /app/apps/web/.next/standalone/apps/web/.next ./.next COPY --from=build --chown=node:node /app/apps/web/.next/static ./.next/static # Copy public assets if any exist (may be empty) COPY --from=build --chown=node:node /app/apps/web/public ./public diff --git a/apps/web/next.config.js b/apps/web/next.config.js index 6b43d7a..5e9ea69 100644 --- a/apps/web/next.config.js +++ b/apps/web/next.config.js @@ -7,6 +7,8 @@ const withNextIntl = createNextIntlPlugin('./i18n/request.ts'); const nextConfig = { reactStrictMode: true, output: 'standalone', + // In monorepo, trace from repo root so standalone output includes all deps + outputFileTracingRoot: require('path').join(__dirname, '../../'), images: { remotePatterns: [ {