Dockerfile 537 B

123456789101112131415161718192021222324252627282930
  1. FROM node:18-alpine
  2. WORKDIR /app
  3. # Copy package files
  4. COPY package*.json ./
  5. # Install dependencies
  6. RUN npm ci --only=production
  7. # Copy source code
  8. COPY . .
  9. # Create non-root user
  10. RUN addgroup -g 1001 -S nodejs
  11. RUN adduser -S nodejs -u 1001
  12. # Change ownership of app folder
  13. RUN chown -R nodejs:nodejs /app
  14. USER nodejs
  15. # Expose port
  16. EXPOSE 5000
  17. # Health check
  18. HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
  19. CMD curl -f http://localhost:5000/health || exit 1
  20. # Start the application
  21. CMD ["npm", "start"]