# ---- builder: npm ci + vite build -----------------------------------------
FROM node:22-alpine AS builder

WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci

COPY . .
RUN npm run build

# ---- runtime: static files served by nginx ---------------------------------
FROM nginx:1.27-alpine AS runtime

COPY --from=builder /app/dist /usr/share/nginx/html
# Rendered to /etc/nginx/conf.d/default.conf at container start by the base
# image's docker-entrypoint.sh, substituting ${BACKEND_UPSTREAM} (set via
# compose env, e.g. "backend:5000").
COPY nginx.conf.template /etc/nginx/templates/default.conf.template

EXPOSE 80
