Updated Docker healthcheck to use 127.0.0.1 for better compatibility. Deployment target: https://audio.kit.pivoine.art
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;"]
|