refactor: update Dockerfile and docker-compose.yml for Next.js 15 optimization and standalone output

This commit is contained in:
hamed
2025-12-10 14:44:41 +03:30
parent 6f0c29d700
commit 8e5e8e1e9d
3 changed files with 9 additions and 8 deletions
+5 -6
View File
@@ -65,12 +65,11 @@ ENV HOSTNAME="0.0.0.0"
RUN addgroup --system --gid 1001 nodejs && \
adduser --system --uid 1001 nextjs
# Copy necessary files from builder
# Copy necessary files from builder (standalone mode)
COPY --from=builder --chown=nextjs:nodejs /app/next.config.js ./
COPY --from=builder --chown=nextjs:nodejs /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next
COPY --from=builder --chown=nextjs:nodejs /app/package.json ./
COPY --from=builder --chown=nextjs:nodejs /app/node_modules ./node_modules
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
# Switch to non-root user
USER nextjs
@@ -85,5 +84,5 @@ HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
# Use dumb-init to handle signals properly
ENTRYPOINT ["dumb-init", "--"]
# Start Next.js in production mode
CMD ["node_modules/.bin/next", "start"]
# Start Next.js in standalone mode
CMD ["node", "server.js"]