mirror of
https://github.com/johndoe6345789/docker-swarm-termina.git
synced 2026-04-24 05:35:21 +00:00
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:
@@ -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"]
|
||||
|
||||
Reference in New Issue
Block a user