# syntax=docker/dockerfile:1 # ---------- Build stage ---------- FROM node:20-alpine AS build WORKDIR /app # Install dependencies (cached unless package files change) COPY package.json package-lock.json ./ RUN npm ci # Build the app COPY . . # API base URL is baked in at build time (Vite inlines VITE_* vars). # Override with: docker build --build-arg VITE_API_URL=https://api.example.com/api/v1 . ARG VITE_API_URL ENV VITE_API_URL=$VITE_API_URL RUN npm run build # ---------- Runtime stage ---------- FROM nginx:alpine AS runtime # SPA-aware nginx config COPY nginx.conf /etc/nginx/conf.d/default.conf # Static build output COPY --from=build /app/dist /usr/share/nginx/html EXPOSE 80 HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ CMD wget -q -O /dev/null http://127.0.0.1/ || exit 1 CMD ["nginx", "-g", "daemon off;"]