# syntax=docker/dockerfile:1 # --- Stage 1: build the production bundle --------------------------------- FROM node:20-alpine AS build WORKDIR /app # Install dependencies first to leverage Docker layer caching. COPY package.json package-lock.json ./ RUN npm ci # Copy application source and build. COPY . . ARG VITE_API_BASE_URL=/api/v1 ENV VITE_API_BASE_URL=$VITE_API_BASE_URL RUN npm run build # --- Stage 2: serve static files with Nginx -------------------------------- FROM nginx:1.27-alpine # SPA + API proxy configuration (proxies /api/ to the backend service). COPY nginx.conf /etc/nginx/conf.d/default.conf # Production bundle from the build stage. COPY --from=build /app/dist /usr/share/nginx/html EXPOSE 80 HEALTHCHECK --interval=30s --timeout=5s --retries=3 \ CMD wget -qO- http://localhost/ >/dev/null 2>&1 || exit 1 CMD ["nginx", "-g", "daemon off;"]