FROM python:3.12-slim AS builder

RUN apt-get update && apt-get install -y curl gnupg procps && \
    curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
    apt-get install -y nodejs && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

WORKDIR /build

RUN pip install --no-cache-dir jupyter-book

COPY docs/jupyter-book/myst.yml docs/jupyter-book/* README.md ./
COPY docs/notebooks/ ./notebooks/

ENV HOST=127.0.0.1

RUN jupyter-book build --html --keep-host

FROM nginx:alpine
COPY --from=builder /build/_build/html /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
