Files
bestofpb/Dockerfile
scott 2dc267c969 fix: production API URL, k8s single replica, health probes
- Change API_URL default from localhost:4000 to empty string (relative URLs)
- Set VITE_API_URL="" explicitly in Dockerfile frontend build stage
- Reduce k8s replicas to 1 (SQLite + ReadWriteOnce PVC)
- Add liveness and readiness probes targeting /health endpoint

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-05 10:21:12 -07:00

52 lines
1.1 KiB
Docker

# Multi-stage build for React Awards Map
FROM node:20-alpine AS frontend-builder
WORKDIR /app/frontend
# Copy frontend package files
COPY frontend/package*.json ./
# Install frontend dependencies
RUN npm ci
# Copy frontend source
COPY frontend/ ./
# Build frontend for production
ENV VITE_API_URL=""
RUN npm run build
# Production stage
FROM node:20-alpine
WORKDIR /app
# Copy backend package files
COPY backend/package*.json ./
# Install production dependencies only
RUN npm ci --only=production
# Copy backend source
COPY backend/ ./
# Copy built frontend from builder stage
COPY --from=frontend-builder /app/frontend/dist ./dist
# Create directory for database
RUN mkdir -p /app/data
# Expose port
EXPOSE 4000
# Set production environment
ENV NODE_ENV=production
ENV DATABASE_PATH=/app/data/awards.db
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD node -e "require('http').get('http://localhost:4000/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"
# Start the application
CMD ["node", "index.js"]