# Build the static docs site, then serve it from nginx.
#
# The build stage carries its own Node 22, so nothing about the host's Node
# matters — which is the whole reason this is dockerised (the Ubuntu apt Node
# 18.19.1 can't build Astro).

# --- build ------------------------------------------------------------------
FROM node:22-alpine AS build
WORKDIR /app

# Install deps first so this layer caches unless the lockfile changes.
COPY package.json package-lock.json ./
RUN npm ci

COPY . .
RUN npm run build

# --- serve ------------------------------------------------------------------
FROM nginx:1.27-alpine AS serve
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /app/dist /usr/share/nginx/html
EXPOSE 80
HEALTHCHECK --interval=30s --timeout=3s \
  CMD wget -qO- http://localhost/ >/dev/null 2>&1 || exit 1
