# Build container
FROM debian:bullseye-slim AS build
# Set build workdir
WORKDIR /usr/src/app
# Install wget
RUN apt update && apt install -y wget
# Download mdBook
RUN wget -O mdbook.tar.gz -- https://github.com/rust-lang/mdBook/releases/download/v0.4.35/mdbook-v0.4.35-x86_64-unknown-linux-gnu.tar.gz && tar -xvf mdbook.tar.gz
# Copy sources
COPY . .
# Build book
RUN ./mdbook build
# ---
# Production container
FROM nginx:1.25.2-alpine
# Copy static files
COPY --from=build /usr/src/app/book/ /usr/share/nginx/html/