# Pantry Production Dockerfile # Multi-stage build for optimized production image # Stage 1: Build the Nuxt application FROM node:20-alpine AS builder # Set working directory WORKDIR /app # Copy package files COPY app/package*.json ./ # Install dependencies RUN npm ci --only=production && \ npm cache clean --force # Copy application source COPY app/ ./ # Build the application RUN npm run build # Stage 2: Production runtime FROM node:20-alpine AS runner # Install dumb-init for proper signal handling RUN apk add --no-cache dumb-init # Create app user RUN addgroup -g 1001 -S nodejs && \ adduser -S nodejs -u 1001 # Set working directory WORKDIR /app # Copy built application from builder COPY --from=builder --chown=nodejs:nodejs /app/.output /app/.output COPY --from=builder --chown=nodejs:nodejs /app/package*.json ./ # Switch to non-root user USER nodejs # Expose port EXPOSE 3000 # Set environment variables ENV NODE_ENV=production \ HOST=0.0.0.0 \ PORT=3000 # Health check HEALTHCHECK --interval=30s --timeout=3s --start-period=40s --retries=3 \ CMD node -e "require('http').get('http://localhost:3000/api/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})" # Use dumb-init to handle signals properly ENTRYPOINT ["dumb-init", "--"] # Start the application CMD ["node", ".output/server/index.mjs"]