Changed healthcheck from localhost to 127.0.0.1 to force IPv4 connection. The issue occurred because 'localhost' resolves to IPv6 (::1) but nginx only listens on IPv4 by default, causing healthchecks to fail. Error before fix: Connecting to localhost ([::1]:80) wget: can't connect to remote host: Connection refused Updated both Dockerfile and docker-compose.yml for consistency. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
57 lines
1.3 KiB
Docker
57 lines
1.3 KiB
Docker
# Pastel UI - Static Export Docker Image
|
|
# Lightweight nginx-based static file server
|
|
|
|
# Stage 1: Dependencies
|
|
FROM node:20-alpine AS deps
|
|
RUN corepack enable && corepack prepare pnpm@latest --activate
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy package files
|
|
COPY package.json pnpm-lock.yaml ./
|
|
|
|
# Install dependencies
|
|
RUN pnpm install --frozen-lockfile
|
|
|
|
# Stage 2: Builder
|
|
FROM node:20-alpine AS builder
|
|
RUN corepack enable && corepack prepare pnpm@latest --activate
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy dependencies from deps stage
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
|
|
# Copy source files
|
|
COPY . .
|
|
|
|
# Set build-time environment variables
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
ENV NODE_ENV=production
|
|
|
|
# Build static export
|
|
RUN pnpm build
|
|
|
|
# Stage 3: Production (nginx)
|
|
FROM nginx:alpine AS runner
|
|
|
|
# Copy static files to nginx html directory
|
|
COPY --from=builder /app/out /usr/share/nginx/html
|
|
|
|
# Copy custom nginx configuration for SPA routing and WASM support
|
|
COPY nginx.conf /etc/nginx/nginx.conf
|
|
|
|
# Create non-root user for nginx
|
|
RUN chown -R nginx:nginx /usr/share/nginx/html && \
|
|
chmod -R 755 /usr/share/nginx/html
|
|
|
|
# Expose port 80
|
|
EXPOSE 80
|
|
|
|
# Health check (use 127.0.0.1 to force IPv4)
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
|
CMD wget --no-verbose --tries=1 --spider http://127.0.0.1/ || exit 1
|
|
|
|
# Run nginx
|
|
CMD ["nginx", "-g", "daemon off;"]
|