# Stage 1: Builder - install dependencies and build docs
FROM python:3.11-slim as builder
# Install build dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends git && \
rm -rf /var/lib/apt/lists/*
# Set workdir and copy repo
WORKDIR /src
COPY . .
# Install Python dependencies including MkDocs and plugins
RUN python -m pip install --no-cache-dir --upgrade pip && \
python -m pip install --no-cache-dir \
mkdocs \
mkdocs-material \
mkdocs-video \
mkdocs-redirects \
mkdocs-glightbox \
mkdocs-rss-plugin \
git+https://github.com/pikvm/markdown-include
# Build MkDocs site
RUN mkdocs build
# Stage 2: Runtime
FROM python:3.11-slim
# Expose port for the static site server
EXPOSE 8000
WORKDIR /site
COPY --from=builder /src/site /site
CMD ["python","-m","http.server","8000","--bind","0.0.0.0"]
# Ignore git repository information .git .gitignore # Node node_modules/ # Build artifacts build/ dist/ *.egg-info/ *.pyc __pycache__/ # OS files .DS_Store Thumbs.db # Logs *.log # Packaging *.tar.gz *.zip # Documentation build outputs (we rely on MkDocs to build) site/
Concerns: Final image serves static content via Python's http.server; lacks a real application server or health check. If dynamic behavior is required, consider a more robust server and a healthcheck., MkDocs build depends on network access to install dependencies during the build stage; ensure CI has network access and compatibility with the pinned packages. Smoke [PASS]: test -f /site/index.html Smoke [PASS]: grep -q '</html>' /site/index.html Smoke [PASS]: ls -la /site | head -n 5