# Multi-stage Dockerfile for MCPTesta Documentation # Supports both development and production modes # Base stage with Node.js FROM node:20-alpine AS base WORKDIR /app # Install system dependencies RUN apk add --no-cache \ dumb-init \ curl \ wget \ && rm -rf /var/cache/apk/* # Create non-root user RUN addgroup -g 1001 -S nodejs && \ adduser -S astro -u 1001 -G nodejs # Copy package files COPY package*.json ./ # Dependencies stage FROM base AS deps RUN npm ci --only=production && npm cache clean --force # Development dependencies stage FROM base AS dev-deps RUN npm ci && npm cache clean --force # Builder stage for production builds FROM dev-deps AS builder COPY . . RUN npm run build # Development stage with hot reloading FROM dev-deps AS development COPY . . # Change ownership to non-root user RUN chown -R astro:nodejs /app USER astro EXPOSE 4321 # Health check HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \ CMD wget --no-verbose --tries=1 --spider http://localhost:4321/ || exit 1 # Use dumb-init for proper signal handling ENTRYPOINT ["dumb-init", "--"] CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0", "--port", "4321"] # Production stage with static files FROM nginx:alpine AS production # Install security updates RUN apk update && apk upgrade && \ apk add --no-cache dumb-init && \ rm -rf /var/cache/apk/* # Copy built site from builder stage COPY --from=builder /app/dist /usr/share/nginx/html # Custom nginx configuration for Astro COPY <