From 8e5e8e1e9d09ed54818b4cef1145977292ad1101 Mon Sep 17 00:00:00 2001 From: hamed <15238-genius.ha@users.noreply.drupalcode.org> Date: Wed, 10 Dec 2025 14:44:41 +0330 Subject: [PATCH] refactor: update Dockerfile and docker-compose.yml for Next.js 15 optimization and standalone output --- docker-compose.yml | 4 ++-- dockerfile | 11 +++++------ next.config.js | 2 ++ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index d83edf1..2df9e95 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -80,12 +80,12 @@ services: # - /tmp # - /app/.next/cache - # Networks (Coolify uses bridge network) + # Networks networks: - coolify # Network configuration networks: coolify: - driver: bridge + name: coolify external: true diff --git a/dockerfile b/dockerfile index 01e19f7..2d1cc46 100644 --- a/dockerfile +++ b/dockerfile @@ -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"] \ No newline at end of file +# Start Next.js in standalone mode +CMD ["node", "server.js"] \ No newline at end of file diff --git a/next.config.js b/next.config.js index dac4b5c..365e829 100644 --- a/next.config.js +++ b/next.config.js @@ -23,6 +23,8 @@ const nextConfig = { trailingSlash: false, compress: true, poweredByHeader: false, + // Enable standalone output for Docker + output: 'standalone', }; module.exports = nextConfig;