# ── Stage 1: Build Astro static site ─────────────────────────────────────────
FROM node:22-alpine AS builder

WORKDIR /app

COPY zonemaster-gui/package*.json ./
RUN npm ci

COPY zonemaster-gui/ ./

# Build as static production site with Spanish as default, API proxied via /api
ENV NODE_ENV=production
ENV PUBLIC_API_URL=/api
ENV PUBLIC_BASE_URL=/
RUN npm run build

# ── Stage 2: Serve with nginx ─────────────────────────────────────────────────
FROM nginx:alpine

COPY --from=builder /app/public/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf

EXPOSE 80
