# Build stage FROM node:20-alpine AS builder WORKDIR /app # Copy package files COPY package*.json ./ # Install all dependencies (including client devDependencies for build) RUN npm install # Copy client source for build COPY client/ ./client/ # Build the client RUN npm run build # Production stage FROM node:20-alpine # Install system dependencies for node-canvas and sharp RUN apk add --no-cache \ cairo-dev \ pango-dev \ libjpeg-turbo-dev \ giflib-dev \ librsvg-dev \ pixman-dev \ python3 \ make \ g++ WORKDIR /app # Copy package files and install production dependencies only COPY package*.json ./ RUN npm install --production # Copy server source COPY server/ ./server/ # Copy built client from builder COPY --from=builder /app/client/dist ./server/dist # Create data directories RUN mkdir -p /app/server/uploads /app/server/exports # Health check HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ CMD wget --no-verbose --tries=1 --spider http://localhost:3001/api/health || exit 1 EXPOSE 3001 CMD ["node", "server/index.js"]