This document explains how to run CodeWiki using Docker and Docker Compose.
The Docker setup provides a containerized environment for running the CodeWiki web application, which allows you to generate documentation for GitHub repositories through a web interface.
All Docker-related files are located in the docker/ directory:
docker/
├── Dockerfile # Container image definition
├── docker-compose.yml # Service orchestration
├── env.example # Environment variables template
└── DOCKER_README.md # This file
The Dockerfile builds from the project root context to include all necessary application code.
git clone <repository-url>
cd CodeWiki# Copy the example environment file
cp docker/env.example .env
# Edit .env file with your configuration
nano .env # or use your preferred editorRequired configuration in .env:
# LLM API Configuration
MAIN_MODEL=claude-sonnet-4
FALLBACK_MODEL_1=glm-4p5
CLUSTER_MODEL=claude-sonnet-4
LLM_BASE_URL=https://api.anthropic.com # or your LiteLLM proxy
LLM_API_KEY=your-api-key-here
# Application Port
APP_PORT=8000
# Optional: Logfire Configuration (for monitoring)
LOGFIRE_TOKEN=
LOGFIRE_PROJECT_NAME=codewiki
LOGFIRE_SERVICE_NAME=codewikidocker network create codewiki-networkOption A: From project root
docker-compose -f docker/docker-compose.yml up -d- Web Application: http://localhost:8000
The application will be available at the port specified in your .env file (default: 8000).
The docker-compose.yml file defines the CodeWiki service with the following features:
- Image:
codewiki:0.0.1 - Build Context: Parent directory (
.relative to docker/) - Container Name:
codewiki - Port Mapping:
${APP_PORT:-8000}:8000 - Network:
codewiki-network(external)
The container uses environment variables from the .env file:
PYTHONPATH=/app/src- Set Python module pathPYTHONUNBUFFERED=1- Enable real-time logging- All variables from
.envfile
The following directories are mounted as volumes:
volumes:
- ./output:/app/output # Persistent storage for generated docs
- ~/.ssh:/root/.ssh:ro # SSH keys for private repos (read-only)Note: Git credentials can be mounted if needed for private repositories:
# Uncomment in docker-compose.yml if needed
- ~/.gitconfig:/root/.gitconfig:roThe service includes a health check that:
- Runs every 30 seconds
- Times out after 10 seconds
- Retries 3 times on failure
- Starts checking after 20 seconds
The container is set to restart automatically unless explicitly stopped (restart: unless-stopped).
The Dockerfile (docker/Dockerfile) builds the CodeWiki image with:
- Python 3.12 slim image for smaller size
git- For repository cloningcurl- For health checksnodejsandnpm- For mermaid diagram validation
- Copies
requirements.txtfirst (for better caching) - Installs Python dependencies
- Copies entire application code
- Creates output directories:
output/cacheoutput/tempoutput/docsoutput/dependency_graphs
- Working Directory:
/app - Exposed Port:
8000 - Entry Point:
python codewiki/run_web_app.py --host 0.0.0.0 --port 8000
# From project root
docker-compose -f docker/docker-compose.yml logs -f
# From docker directory
cd docker
docker-compose logs -f
# View specific service
docker logs codewiki -f# From project root
docker-compose -f docker/docker-compose.yml stop
# From docker directory
cd docker
docker-compose stop# From project root
docker-compose -f docker/docker-compose.yml down
# From docker directory
cd docker
docker-compose down
# Remove volumes as well
docker-compose down -vIf you've made changes to the code or Dockerfile:
# From project root
docker-compose -f docker/docker-compose.yml build --no-cache
# From docker directory
cd docker
docker-compose build --no-cache
# Rebuild and restart
docker-compose up -d --builddocker exec -it codewiki /bin/bashThe output/ directory is mounted as a volume, ensuring generated documentation persists across container restarts:
output/
├── cache/ # Cached dependency graphs and jobs
├── docs/ # Generated documentation
├── dependency_graphs/ # JSON dependency graphs
└── temp/ # Temporary files
If you need to clone private repositories, ensure your SSH keys are available:
# Verify SSH keys are accessible
ls -la ~/.ssh/
# The docker-compose.yml mounts ~/.ssh as read-onlyIf port 8000 is already in use:
# Change APP_PORT in .env file
echo "APP_PORT=8001" >> .env
# Restart services
docker-compose -f docker/docker-compose.yml down
docker-compose -f docker/docker-compose.yml up -dCheck logs for errors:
docker logs codewikiCommon issues:
- Invalid API key: Verify
LLM_API_KEYin.env - Network not found: Create network with
docker network create codewiki-network - Port conflict: Change
APP_PORTin.env
# Check if the application is responding
curl http://localhost:8000/
# Check container health status
docker inspect codewiki --format='{{.State.Health.Status}}'
# View health check logs
docker inspect codewiki --format='{{range .State.Health.Log}}{{.Output}}{{end}}'If you encounter permission issues with mounted volumes:
# On Linux, ensure proper ownership
sudo chown -R $(id -u):$(id -g) output/
# Or run container with user mapping
docker-compose -f docker/docker-compose.yml down
# Add to docker-compose.yml under 'codewiki' service:
# user: "${UID}:${GID}"For private repositories:
-
Ensure SSH keys are properly mounted:
volumes: - ~/.ssh:/root/.ssh:ro
-
Verify key permissions:
chmod 600 ~/.ssh/id_rsa chmod 644 ~/.ssh/id_rsa.pub
-
Add GitHub to known_hosts:
docker exec -it codewiki ssh-keyscan github.com >> /root/.ssh/known_hosts
- Environment Variables: Never commit
.envfile to version control - API Keys: Use secrets management in production
- Network: Use isolated Docker networks
- Volumes: Set appropriate permissions on mounted volumes
- Updates: Regularly update base image and dependencies
# Use secrets instead of .env file
services:
codewiki:
secrets:
- llm_api_key
environment:
- LLM_API_KEY_FILE=/run/secrets/llm_api_key
secrets:
llm_api_key:
external: trueAdd resource limits in production:
services:
codewiki:
deploy:
resources:
limits:
cpus: '2'
memory: 4G
reservations:
cpus: '1'
memory: 2GUse nginx or traefik as a reverse proxy:
services:
nginx:
image: nginx:alpine
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
- ./certs:/etc/nginx/certs:roIf using a LiteLLM proxy for LLM API management:
# In .env file
LLM_BASE_URL=http://litellm:4000/
LLM_API_KEY=sk-your-proxy-key
# Add LiteLLM service to docker-compose.yml
services:
litellm:
image: ghcr.io/berriai/litellm:latest
ports:
- "4000:4000"
environment:
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
- OPENAI_API_KEY=${OPENAI_API_KEY}
networks:
- codewiki-network- Main Documentation: See ../README.md for complete feature list and usage
- CLI Tool: For command-line documentation generation
- Web Interface: For GitHub URL-based documentation generation
For issues related to Docker deployment:
- Check logs:
docker logs codewiki - Verify configuration:
docker exec codewiki env | grep -E '(LLM|APP)' - Test connectivity:
docker exec codewiki curl -I http://localhost:8000 - Report issues: https://github.com/yourusername/codewiki/issues
Happy documenting with Docker! 🐳📚