# syntax=docker/dockerfile:1.7
#
# Build container for @suaveplan/docs.
#
# This image holds the Docusaurus toolchain (Node 22 LTS + npm + docusaurus
# deps). It is run via docker-compose to consume a snapshot of the repo's
# markdown content (mounted as `/work/docs`) and produce the static build
# output (mounted as `/work/build` -> host `apps/docs/build/`).
#
# The Bun bytecode-compiled runtime server lives outside this image.
FROM node:22-bookworm-slim

ENV DEBIAN_FRONTEND=noninteractive
ENV NODE_ENV=production
ENV NPM_CONFIG_FUND=false
ENV NPM_CONFIG_AUDIT=false

WORKDIR /work

# Toolchain deps first so the layer caches when only content changes.
COPY package.json ./

RUN npm install --no-save --omit=optional

# Site configuration — these change rarely, content changes often.
COPY docusaurus.config.ts sidebars.ts ./
COPY src ./src
COPY tsconfig.json ./

# Output to a subdirectory of the mounted volume so Docusaurus can rmdir
# its own output between runs without touching the bind mount itself.
CMD ["npx", "docusaurus", "build", "--out-dir", "/work/build/site"]
