jakevdp-pythondatasciencehandbook
SUCCESS
15m 32s
History Source
SummaryIterations2Transcript16Dockerfile
Dockerfile42 lines · 974 chars
# Builder stage: install Pelican and build the site
FROM python:3.12-slim as builder

WORKDIR /src

ENV DEBIAN_FRONTEND=noninteractive

# Install system dependencies
RUN apt-get update \
    && apt-get install -y --no-install-recommends \
      build-essential \
      ca-certificates \
      curl \
    && rm -rf /var/lib/apt/lists/*

# Upgrade pip
RUN python -m pip install --no-cache-dir --upgrade pip

# Copy repository
COPY . .

# Install Pelican (and only minimal necessary deps to build the site)
RUN pip install --no-cache-dir pelican

# Build the Pelican site
RUN make -C website html


# Runtime stage: serve the static site with Python's built-in server
FROM python:3.12-slim

WORKDIR /app

# Copy the generated site from the builder
COPY --from=builder /src/website/output /app/output

# Expose port for serving the site
EXPOSE 8000

# Serve the static site with Python's built-in HTTP server
CMD ["python", "-m", "http.server", "8000", "--directory", "output"]