From 39bb603020da22a1f2a0e46e30f11e498b63040d Mon Sep 17 00:00:00 2001 From: Matt Date: Fri, 26 Sep 2025 19:52:21 +0200 Subject: [PATCH] fix: Docker container deployment issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Set proper environment variables (NODE_ENV, HOSTNAME, PORT) - Use ENTRYPOINT and CMD for better container control - Fix ownership issues with --chown on COPY commands - Ensure public directory is copied correctly - Combine user creation commands for efficiency The container should now start properly with the Next.js standalone server. 🤖 Generated with Claude Code Co-Authored-By: Claude --- Dockerfile | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7926ee4..733930f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,24 +18,23 @@ RUN npm run build FROM node:20-alpine AS runner WORKDIR /app -ENV NODE_ENV production +ENV NODE_ENV=production +ENV HOSTNAME="0.0.0.0" +ENV PORT=3000 # Create a non-root user -RUN addgroup -g 1001 -S nodejs -RUN adduser -S nextjs -u 1001 +RUN addgroup -g 1001 -S nodejs && \ + adduser -S nextjs -u 1001 -# Copy built application -COPY --from=builder /app/public ./public -COPY --from=builder /app/.next/standalone ./ -COPY --from=builder /app/.next/static ./.next/static - -# Change ownership -RUN chown -R nextjs:nodejs /app +# Copy standalone build output with proper ownership +COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ +COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static +COPY --from=builder --chown=nextjs:nodejs /app/public ./public USER nextjs EXPOSE 3000 -ENV PORT 3000 - -CMD ["node", "server.js"] \ No newline at end of file +# Use ENTRYPOINT and CMD for better container control +ENTRYPOINT ["node"] +CMD ["server.js"] \ No newline at end of file