Add multi-stage Dockerfile and nginx configuration: **Dockerfile** - Stage 1: Build with Node.js 22 Alpine and pnpm 9 - Stage 2: Serve with nginx 1.27 Alpine - Static export optimization - Health check endpoint **nginx.conf** - Gzip compression for assets - CORS headers for Canvas API - Cache static assets (1 year) - Don't cache HTML files - Support for WebAssembly files - Security headers - Client max body size: 100M for large image uploads Ready for containerized deployment. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
42 lines
920 B
Docker
42 lines
920 B
Docker
# Multi-stage build for Next.js static export
|
|
|
|
# Stage 1: Build the application
|
|
FROM node:22-alpine AS builder
|
|
|
|
# Install pnpm
|
|
RUN corepack enable && corepack prepare pnpm@9.0.0 --activate
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Copy package files
|
|
COPY package.json pnpm-lock.yaml* ./
|
|
|
|
# Install dependencies
|
|
RUN pnpm install --frozen-lockfile
|
|
|
|
# Copy application files
|
|
COPY . .
|
|
|
|
# Build the Next.js application (static export)
|
|
RUN pnpm build
|
|
|
|
# Stage 2: Production server with nginx
|
|
FROM nginx:1.27-alpine AS runner
|
|
|
|
# Copy custom nginx configuration
|
|
COPY nginx.conf /etc/nginx/nginx.conf
|
|
|
|
# Copy built static files from builder stage
|
|
COPY --from=builder /app/out /usr/share/nginx/html
|
|
|
|
# Expose port 80
|
|
EXPOSE 80
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
|
CMD wget --quiet --tries=1 --spider http://127.0.0.1/ || exit 1
|
|
|
|
# Start nginx
|
|
CMD ["nginx", "-g", "daemon off;"]
|