fix: Docker container deployment issues
All checks were successful
build-website / build (push) Successful in 2m14s
All checks were successful
build-website / build (push) Successful in 2m14s
- 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 <noreply@anthropic.com>
This commit is contained in:
25
Dockerfile
25
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"]
|
||||
# Use ENTRYPOINT and CMD for better container control
|
||||
ENTRYPOINT ["node"]
|
||||
CMD ["server.js"]
|
||||
Reference in New Issue
Block a user