Add comprehensive Docker deployment with automated builds: **Docker Configuration:** - Multi-stage Dockerfile for optimized Next.js production builds - Stage 1: Install dependencies with pnpm - Stage 2: Build application with standalone output - Stage 3: Minimal runtime image with non-root user - Includes health check endpoint - Final image size optimized - .dockerignore for efficient build context - Enable standalone output in next.config.ts for Docker **GitHub Actions Workflow:** - Automated Docker image builds on push to main and tags - Multi-platform support (linux/amd64, linux/arm64) - Push to GitHub Container Registry (ghcr.io) - Smart tagging strategy: - `latest` for main branch - `vX.X.X` for semver tags - `main-SHA` for commit-specific images - Build cache optimization with GitHub Actions cache - Artifact attestation for supply chain security **Docker Compose:** - Combined stack for UI + API - Environment variable configuration - Health checks for both services - Automatic restart policies - Shared network configuration **Documentation:** - Updated README with Docker deployment instructions - Pre-built image usage from GHCR - Docker Compose setup guide - Local build instructions - Available image tags reference **Production Ready:** - Images automatically published to ghcr.io/valknarness/pastel-ui - Supports both x64 and ARM64 architectures - Health checks for container orchestration - Environment-based configuration - Non-root user for security 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
64 lines
1.4 KiB
Docker
64 lines
1.4 KiB
Docker
# Pastel UI - Production Docker Image
|
|
# Multi-stage build for optimized Next.js 16 application
|
|
|
|
# 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 --prod=false
|
|
|
|
# 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 the application
|
|
RUN pnpm build
|
|
|
|
# Stage 3: Runner
|
|
FROM node:20-alpine AS runner
|
|
|
|
WORKDIR /app
|
|
|
|
ENV NODE_ENV=production
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
|
|
# Create non-root user
|
|
RUN addgroup --system --gid 1001 nodejs && \
|
|
adduser --system --uid 1001 nextjs
|
|
|
|
# Copy built application
|
|
COPY --from=builder /app/public ./public
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
|
|
|
USER nextjs
|
|
|
|
EXPOSE 3000
|
|
|
|
ENV PORT=3000
|
|
ENV HOSTNAME="0.0.0.0"
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
|
CMD node -e "require('http').get('http://localhost:3000/api/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"
|
|
|
|
CMD ["node", "server.js"]
|