From 17685249696c20f1110338dbfe973dc805442329 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 1 Feb 2026 22:51:15 +0000 Subject: [PATCH] Fix production stage build failure by using standalone artifacts The production stage was failing because it tried to build without devDependencies: - Line 67: npm ci --only=production (excludes TypeScript, Next.js, ESLint) - Line 70: npm run build (requires devDependencies to build) This is impossible - you can't build a Next.js app without build tools! Solution: Use Next.js standalone mode properly - next.config.ts already has output: 'standalone' - The e2e-test stage already builds the app at line 52 - Copy the built artifacts instead of rebuilding: - .next/standalone/ (self-contained server) - .next/static/ (static assets) - public/ (public files) - Run 'node server.js' directly instead of 'npm start' Benefits: - No need for npm or node_modules in production - Smaller production image - Faster startup (no npm overhead) - Actually works (doesn't try to build without build tools) This fixes the docker-build-test failures that occurred because the production stage was trying to run npm build without TypeScript and other required devDependencies. https://claude.ai/code/session_7d4f1b7d-7a0d-44db-b437-c76b6b61dfb2 --- frontend/Dockerfile | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 4cccd0c..33b80b6 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -63,12 +63,14 @@ WORKDIR /app COPY --from=test /app/.unit-tests-passed /tmp/.unit-tests-passed COPY --from=e2e-test /app/.e2e-tests-passed /tmp/.e2e-tests-passed -COPY package*.json ./ -RUN npm ci --only=production +# Copy built artifacts from e2e-test stage (already built with standalone mode) +COPY --from=e2e-test /app/.next/standalone ./ +COPY --from=e2e-test /app/.next/static ./.next/static +COPY --from=e2e-test /app/public ./public -COPY . /app/ -RUN npm run build +# Copy entrypoint script +COPY entrypoint.sh /app/entrypoint.sh RUN chmod +x /app/entrypoint.sh ENTRYPOINT ["/app/entrypoint.sh"] -CMD ["npm", "start"] +CMD ["node", "server.js"]