# Multi-stage build for Restitution # Stage 1: Build (Node.js + webpack) FROM node:20-alpine AS builder # Install build deps for canvas (native module) RUN apk add --no-cache build-base python3 cairo-dev pango-dev giflib-dev jpeg-dev WORKDIR /app COPY package*.json ./ RUN npm install --legacy-peer-deps COPY . . RUN npx webpack --mode production --output-path ./dist # Stage 2: Backend (Colyseus authoritative server) FROM node:20-alpine AS backend WORKDIR /app COPY gameServer/ ./ RUN npm install EXPOSE 8081 CMD ["npm", "start"] # Stage 3: Frontend (Nginx) FROM nginx:alpine AS frontend COPY --from=builder /app/dist/ /usr/share/nginx/html COPY nginx.conf /etc/nginx/conf.d/default.conf EXPOSE 80 CMD ["nginx", "-g", "daemon off;"]