Skip to content

๐Ÿณ Docker Setup Guide

Comprehensive guide for running MkDocForge with Docker

๐Ÿ—๏ธ Project Structure

Text Only
.
โ”œโ”€โ”€ Dockerfile
โ”œโ”€โ”€ docker-compose.yml
โ”œโ”€โ”€ docs/
โ””โ”€โ”€ ...

๐Ÿš€ Quick Start

1๏ธโƒฃ Build and Run with Docker Compose

Bash
docker-compose up

2๏ธโƒฃ Access the Documentation

Open your browser at http://localhost:8000

๐Ÿ”ง Configuration Options

Environment Variables

Variable Description Default
PYTHONUNBUFFERED Enable unbuffered output 1
PYTHONDONTWRITEBYTECODE Prevent .pyc files 1

Port Configuration

Port Description
8000 MkDocs development server

๐Ÿ› ๏ธ Common Commands

Command Description
docker-compose up Start the container
docker-compose up -d Start in detached mode
docker-compose down Stop and remove containers
docker-compose build Rebuild the image
docker-compose logs View container logs

๐Ÿ› ๏ธ Build and Run

Bash
# Build with progress output
docker compose -f docker-compose.yml build --progress=plain

# Start in detached mode
docker compose -f docker-compose.yml up -d

๐Ÿ” Monitoring and Inspection

Bash
# View container logs
docker compose -f docker-compose.yml logs -f

# List all containers
docker compose -f docker-compose.yml ps -a

๐Ÿงน Cleanup

Bash
# Stop and remove containers with volumes
docker compose -f docker-compose.yml down -v

๐Ÿ’ก Tip: Use these commands to manage your MkDocForge container lifecycle efficiently

๐Ÿ”„ Development Workflow

  1. Make changes to your documentation
  2. Changes are automatically reloaded in the container
  3. View updates in your browser

๐Ÿงน Cleanup

To remove all Docker artifacts:

Bash
docker-compose down --rmi all --volumes

โš™๏ธ Customization

Dockerfile

Docker
# ๐Ÿณ MkDocForge Dockerfile

# Stage 1: Build Doxygen
FROM python:3.11-slim-bullseye AS doxygen-builder

RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential \
    cmake \
    flex \
    bison \
    git \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /doxygen
RUN git clone https://github.com/doxygen/doxygen.git . && \
    mkdir build && \
    cd build && \
    cmake -G "Unix Makefiles" .. && \
    make && \
    make install

# Stage 2: Build MkDocForge
FROM python:3.11-slim-bullseye

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    PIP_NO_CACHE_DIR=1


# Copy Doxygen from builder
COPY --from=doxygen-builder /usr/local/bin/doxygen /usr/local/bin/doxygen

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

# Install pip and uv
RUN pip install -U pip && pip install uv

# Set work directory
WORKDIR /app

# Copy project files
COPY pyproject.toml .

# Install project docs's dependencies
RUN uv pip install --no-cache --system -e .[docs]

# Verify Doxygen installation
RUN doxygen --version

EXPOSE 8000

# Start MkDocs server
CMD ["uv", "run", "mkdocs", "serve", "--dev-addr=0.0.0.0:8000"]

docker-compose.yml

YAML
---
name: 'mkdocforge'

services:
  mkdocforge:
    container_name: mkdocforge
    image: mkdocforge:v1
    restart: always
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - '8000:8000'
    volumes:
      - .:/app
    environment:
      - PYTHONUNBUFFERED=1
    command: mkdocs serve --dev-addr=0.0.0.0:8000

๐Ÿ Python Docker Image Comparison

๐Ÿ“Š Feature Matrix

Feature python:3.11-slim-bullseye python:3.11-bullseye python:3.11-alpine
Size ~120MB ~900MB ~50MB
Base OS Debian Slim Debian Alpine Linux
Package Manager apt apt apk
Build Tools Limited Full Minimal
Security Good Standard Excellent
Compatibility High Very High Medium

๐ŸŽฏ Use Cases

python:3.11-slim-bullseye

  • ๐Ÿ† Best for: Production deployments
  • โœ… Pros:
    • Small footprint
    • Good security
    • Wide compatibility
  • โš ๏ธ Cons:
    • Limited system packages

python:3.11-bullseye

  • ๐Ÿ† Best for: Development environments
  • โœ… Pros:
    • Full Debian environment
    • Easy to use
    • Wide package availability
  • โš ๏ธ Cons:
    • Large image size

python:3.11-alpine

  • ๐Ÿ† Best for: Minimalist deployments
  • โœ… Pros:
    • Smallest size
    • Excellent security
    • Musl libc
  • โš ๏ธ Cons:
    • Potential compatibility issues
    • Limited package availability

๐Ÿค” Why We Chose python:3.11-slim-bullseye

  1. Optimal Balance: Combines small size with good compatibility
  2. Security: Regular security updates from Debian
  3. Efficiency: Minimal overhead for production use
  4. Maintainability: Easier to manage than Alpine

๐Ÿ’ก Tip: Consider using multi-stage builds for even smaller final images

๐Ÿ“š Resources

Resource Description
Docker Documentation Official Docker docs
Docker Compose Reference Compose file reference
MkDocs Docker Guide MkDocs deployment guide

๐Ÿ’ก Tip: Use Docker volumes for persistent data and faster development cycles