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
This commit is contained in:
Claude
2026-02-01 22:51:15 +00:00
parent 45d6e9be44
commit 1768524969

View File

@@ -63,12 +63,14 @@ WORKDIR /app
COPY --from=test /app/.unit-tests-passed /tmp/.unit-tests-passed COPY --from=test /app/.unit-tests-passed /tmp/.unit-tests-passed
COPY --from=e2e-test /app/.e2e-tests-passed /tmp/.e2e-tests-passed COPY --from=e2e-test /app/.e2e-tests-passed /tmp/.e2e-tests-passed
COPY package*.json ./ # Copy built artifacts from e2e-test stage (already built with standalone mode)
RUN npm ci --only=production 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/ # Copy entrypoint script
RUN npm run build COPY entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh RUN chmod +x /app/entrypoint.sh
ENTRYPOINT ["/app/entrypoint.sh"] ENTRYPOINT ["/app/entrypoint.sh"]
CMD ["npm", "start"] CMD ["node", "server.js"]