FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
# Vite bakes env at build time. Keep this to the generic surface every Aratika
# app needs, and add your own VITE_* build args here (analytics, feature flags…).
#   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); supplied by the deploy runner.
ARG VITE_API_BASE_URL=""
ARG VITE_DEPLOY_ID=""
ENV VITE_API_BASE_URL=${VITE_API_BASE_URL} \
    VITE_DEPLOY_ID=${VITE_DEPLOY_ID}
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;"]
