- Multi-stage Dockerfile with Node.js 20 Alpine base - Production and development docker-compose configurations - Health check API endpoint for container monitoring - Build and deployment scripts with versioning support - Port 3000 configuration for nginx compatibility - Non-root user and security hardening - Resource limits and logging configuration - Package.json scripts for Docker operations This eliminates dependency conflicts and provides reproducible deployments. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
61 lines
1.6 KiB
Docker
61 lines
1.6 KiB
Docker
# Multi-stage build for Black Canyon Tickets
|
|
# Stage 1: Build stage
|
|
FROM node:20-alpine AS builder
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Copy package files
|
|
COPY package*.json ./
|
|
|
|
# Install all dependencies (including dev dependencies for build)
|
|
RUN npm ci
|
|
|
|
# Copy source code
|
|
COPY . .
|
|
|
|
# Build the application
|
|
RUN npm run build
|
|
|
|
# Stage 2: Production stage
|
|
FROM node:20-alpine AS production
|
|
|
|
# Install security updates
|
|
RUN apk update && apk upgrade && apk add --no-cache dumb-init
|
|
|
|
# Create app user for security
|
|
RUN addgroup -g 1001 -S nodejs
|
|
RUN adduser -S astro -u 1001
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Copy package files
|
|
COPY package*.json ./
|
|
|
|
# Install only production dependencies
|
|
RUN npm ci --only=production && npm cache clean --force
|
|
|
|
# Copy built application from builder stage
|
|
COPY --from=builder --chown=astro:nodejs /app/dist ./dist
|
|
|
|
# Copy additional necessary files
|
|
COPY --chown=astro:nodejs setup-schema.js ./
|
|
COPY --chown=astro:nodejs setup-super-admins.js ./
|
|
|
|
# Create logs directory
|
|
RUN mkdir -p logs && chown astro:nodejs logs
|
|
|
|
# Switch to non-root user
|
|
USER astro
|
|
|
|
# Expose port
|
|
EXPOSE 3000
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
|
CMD node -e "const http=require('http');const options={hostname:'localhost',port:3000,path:'/api/health',timeout:2000};const req=http.request(options,(res)=>{process.exit(res.statusCode===200?0:1)});req.on('error',()=>{process.exit(1)});req.end();" || exit 1
|
|
|
|
# Start the application with dumb-init for proper signal handling
|
|
ENTRYPOINT ["dumb-init", "--"]
|
|
CMD ["node", "./dist/server/entry.mjs"] |