# Track LTS so the image, CI (node-version: 'lts/*') and the site template all
# build on the same Node major. Verified: this template builds clean on
# node:lts-alpine (v24.18.1) — tsc -b + vite build.
FROM node:lts-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
# Vite bakes env at build time. These are passed by CI (.github/workflows/deploy.yml
# build-args ← repo Variables — public, never secrets) and by compose for local
# `--build`. Add your own VITE_* build args here (analytics, feature flags…), and
# wire the same name into deploy.yml.
#   VITE_API_BASE_URL — blank for same-origin (nginx proxies /api); set an
#                       absolute URL only when the API is on a different host.
#   VITE_DEPLOY_ID     — deploy identity baked into the bundle (cache-safety /
#                       "new build available" checks); CI passes github.sha.
ARG VITE_API_BASE_URL=""
ARG VITE_DEPLOY_ID=""
ARG BUILD_SHA=""
ENV VITE_API_BASE_URL=${VITE_API_BASE_URL} \
    VITE_DEPLOY_ID=${VITE_DEPLOY_ID} \
    BUILD_SHA=${BUILD_SHA}
RUN npm run build

FROM nginx:alpine
COPY --from=builder /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
