# Use Debian-based image with better build support FROM node:16-bullseye AS builder # Install system dependencies for node-canvas RUN apt-get update && apt-get install -y \ python3 \ make \ g++ \ libcairo2-dev \ libpango1.0-dev \ libjpeg-dev \ libgif-dev \ librsvg2-dev \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* # Pin known working npm version RUN npm install -g npm@8.19.4 WORKDIR /app COPY package.json package-lock.json ./ # Use legacy peer deps to avoid vite conflict RUN npm install --legacy-peer-deps COPY . . # Optional: skip gen if it fails RUN npm run gen || true RUN npm run build # ---- Runtime image ---- FROM nginx:stable-alpine LABEL org.opencontainers.image.source="https://github.com/sharechess/sharechess" COPY --from=builder /app/dist /usr/share/nginx/html COPY nginx.conf /etc/nginx/conf.d/sharechess.conf RUN rm /etc/nginx/conf.d/default.conf EXPOSE 80 HEALTHCHECK --interval=30s --timeout=5s --start-period=5s \ CMD curl -f http://localhost/ || exit 1 CMD ["nginx", "-g", "daemon off;"]