# syntax=docker/dockerfile:1.7 ARG NODE_VERSION=20.15.0 FROM node:${NODE_VERSION}-alpine AS build WORKDIR /app # Install deps with cache leverage COPY package*.json ./ RUN npm ci || npm install # Build COPY . . ENV NODE_ENV=production ENV NODE_OPTIONS=--max-old-space-size=512 RUN npm run build # ---- Runtime (Nginx) ---- FROM nginx:1.27-alpine AS runtime # Install curl for healthcheck RUN apk add --no-cache curl # Remove default site content RUN rm -rf /usr/share/nginx/html/* # SPA config COPY docker/nginx.conf /etc/nginx/conf.d/default.conf # Static assets COPY --from=build /app/dist /usr/share/nginx/html EXPOSE 80 HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \ CMD curl -fsS http://localhost/ >/dev/null || exit 1 CMD ["nginx", "-g", "daemon off;"]