# syntax=docker/dockerfile:1 # --- Build stage ------------------------------------------------------------- # Build the Vue 3 + Vite SPA into static assets. FROM node:22-alpine AS build WORKDIR /app # Install dependencies against the lockfile for reproducible builds. COPY package.json package-lock.json ./ RUN npm ci COPY . . # VITE_API_BASE is baked into the bundle at build time. Leave empty to use the # same-origin "/api" (nginx proxies it to the API Server — see nginx.conf). ARG VITE_API_BASE RUN npm run build # --- Runtime stage ----------------------------------------------------------- # Serve the built assets with nginx (Alpine-based) and proxy /api upstream. FROM nginx:alpine # nginx substitutes ${API_TARGET} into this template at container start # (only env-defined vars are replaced, so $uri/$host are left intact). COPY nginx.conf.template /etc/nginx/templates/default.conf.template COPY --from=build /app/dist /usr/share/nginx/html # Upstream API Server; override at runtime (compose/`docker run -e`). ENV API_TARGET=http://api-server:8080 EXPOSE 80 # The default nginx entrypoint renders templates then launches nginx.