123456789101112131415161718192021222324252627282930313233 |
- FROM node:18-alpine
- WORKDIR /app
- # Install curl for health check
- RUN apk add --no-cache curl
- # Copy package files
- COPY package*.json ./
- # Install dependencies
- RUN npm install --only=production
- # Copy source code
- COPY . .
- # Create non-root user
- RUN addgroup -g 1001 -S nodejs
- RUN adduser -S nodejs -u 1001
- # Change ownership of app folder
- RUN chown -R nodejs:nodejs /app
- USER nodejs
- # Expose port
- EXPOSE 4000
- # Health check
- HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
- CMD curl -f http://localhost:4000/health || exit 1
- # Start the application
- CMD ["npm", "start"]
|