Skip to content

Commit a3ed673

Browse files
authored
Switch to multi stage build
1 parent 2c3e139 commit a3ed673

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

Dockerfile

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
# Get a python 3.10 image
2-
FROM python:3.10.9
3-
LABEL org.opencontainers.image.source=https://github.com/gbdev/pandocs
4-
SHELL ["bash", "-lc"]
5-
RUN apt update
6-
RUN apt install curl -y
7-
8-
# Install rust and mdbook
9-
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
10-
RUN apt install gcc -y
11-
RUN source "$HOME/.cargo/env"
1+
# --- Stage 1: build mdBook binary ---
2+
FROM rust:1.83 AS builder
123
RUN cargo install mdbook
134

14-
COPY . /code
5+
# --- Stage 2: final Python runtime ---
6+
FROM python:3.10-slim
7+
8+
# Copy mdBook binary only (no Rust toolchain)
9+
COPY --from=builder /usr/local/cargo/bin/mdbook /usr/local/bin/mdbook
10+
11+
# Install dependencies
12+
RUN apt-get update && apt-get install -y curl gcc && rm -rf /var/lib/apt/lists/*
13+
14+
# Set up working directory
1515
WORKDIR /code
16+
COPY . /code
1617

17-
# Init python3 env
18+
# Python environment
1819
RUN python -m venv env
19-
RUN source env/bin/activate
20-
RUN pip install -r requirements.txt
20+
RUN . env/bin/activate && pip install --no-cache-dir -r requirements.txt
2121

22-
# Serve pandocs at localhost:8000
22+
# Build and serve docs
2323
RUN mdbook build
2424
CMD mdbook watch & (cd /code/docs/pandocs/ && python3 -m http.server)

0 commit comments

Comments
 (0)