# ------------------------------------------------------------- # Stage 1: Build the MkDocs site # ------------------------------------------------------------- FROM python:3.11-slim AS builder # 1) Install build prerequisites RUN apt-get update \ && apt-get install -y --no-install-recommends \ gcc git rsync \ && rm -rf /var/lib/apt/lists/* WORKDIR /app # 2) Copy and install dependencies (including mkdocs) COPY requirements.txt mkdocs.yml ./ RUN pip install --no-cache-dir -r requirements.txt mkdocs # 3) Copy your docs source COPY docs/ ./docs # If you have extra markdown or assets outside docs/, add more COPY lines here # 4) Build the static site into /app/site RUN mkdocs build --clean --site-dir site # ------------------------------------------------------------- # Stage 2: Deployer # ------------------------------------------------------------- FROM alpine:3.18 AS deployer # we need rsync in this stage RUN apk add --no-cache rsync WORKDIR /app # Bring the built site in COPY --from=builder /app/site ./site # container will expect you to bind-mount your local nginx docroot into /deploy VOLUME ["/deploy"] COPY --chmod=+x << 'EOF' /usr/local/bin/deploy.sh #!/bin/sh set -e SRC="/app/site/" DST="/deploy/" echo "Deploying site from $SRC to $DST …" # simple sync, deletes stale files on DEST rsync -av --delete "$SRC" "$DST" echo "✅ Deployment complete." EOF ENTRYPOINT ["/usr/local/bin/deploy.sh"] CMD [""] # no-op; all logic in entrypoint