# syntax=docker/dockerfile:1 # PROD image: build static SPA, serve with nginx. Self-contained. # Build context = mcma-webui/. The future prod compose puts a real proxy in # front; this image just serves the built assets with SPA fallback. # -- build stage ---------------------------------------------------------- FROM node:22-slim AS build WORKDIR /app COPY package.json package-lock.json ./ RUN npm ci COPY . . # Build-time default for the API base URL (rsbuild inlines PUBLIC_* vars). This # is only the *fallback* now — the real value is injected at container start by # 30-runtime-config.sh, so the image can target any backend without a rebuild. ARG PUBLIC_API_BASE_URL=/api/v1 ENV PUBLIC_API_BASE_URL=$PUBLIC_API_BASE_URL RUN npm run build # -- runtime stage -------------------------------------------------------- FROM nginx:1.27-alpine AS runtime COPY dockerfiles/nginx.conf /etc/nginx/conf.d/default.conf COPY --from=build /app/dist /usr/share/nginx/html # Runtime config injection: the nginx image runs /docker-entrypoint.d/*.sh # before starting, regenerating /config.js from $PUBLIC_API_BASE_URL. COPY dockerfiles/30-runtime-config.sh /docker-entrypoint.d/30-runtime-config.sh RUN chmod +x /docker-entrypoint.d/30-runtime-config.sh EXPOSE 80 CMD ["nginx", "-g", "daemon off;"]