๐ณ Docker Setup Guide¶
Comprehensive guide for running MkDocForge with Docker
๐๏ธ Project Structure¶
๐ Quick Start¶
1๏ธโฃ Build and Run with Docker Compose¶
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¶
๐ก Tip: Use these commands to manage your MkDocForge container lifecycle efficiently
๐ Development Workflow¶
- Make changes to your documentation
- Changes are automatically reloaded in the container
- View updates in your browser
๐งน Cleanup¶
To remove all Docker artifacts:
โ๏ธ 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
¶
- Optimal Balance: Combines small size with good compatibility
- Security: Regular security updates from Debian
- Efficiency: Minimal overhead for production use
- 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