Skip to content

Docker Deployment

This guide covers deploying Code Search using a single Docker container. This method is suitable for small deployments or testing.

For simple deployments where all components run in one container:

Terminal window
docker run -d \
--name code-search \
-p 8080:8080 \
-p 3000:3000 \
-v code-search-data:/data \
-e CS_DATABASE_URL="postgres://user:pass@host:5432/codesearch" \
-e CS_REDIS_URL="redis://host:6379" \
ghcr.io/techquestsdev/code-search:latest

Configure Code Search using environment variables:

VariableDescriptionDefault
CS_SERVER_ADDRAPI server address:8080
CS_DATABASE_URLPostgreSQL or MySQL connection stringRequired
CS_REDIS_ADDRRedis addresslocalhost:6379
CS_ZOEKT_URLZoekt server URLhttp://localhost:6070
CS_INDEXER_INDEX_PATHZoekt index directory./data/index
CS_INDEXER_REPOS_PATHGit repositories directory./data/repos
CS_REPOS_BASE_PATHBase path for repos./data/repos

See Environment Variables for the complete list.

Mount these volumes for data persistence:

Terminal window
docker run -d \
--name code-search \
-v /path/to/data:/data \ # All data
-v /path/to/config:/config \ # Configuration
ghcr.io/techquestsdev/code-search:latest

Volume structure:

/data/
├── index/ # Zoekt search indexes
├── repos/ # Cloned Git repositories
└── logs/ # Application logs

Code Search supports PostgreSQL 14+ or MySQL 8+. Example with PostgreSQL:

Terminal window
docker run -d \
--name code-search-postgres \
-e POSTGRES_USER=codesearch \
-e POSTGRES_PASSWORD=secret \
-e POSTGRES_DB=codesearch \
-v postgres-data:/var/lib/postgresql/data \
postgres:16-alpine

Redis 7+ is required for the job queue:

Terminal window
docker run -d \
--name code-search-redis \
-v redis-data:/data \
redis:7-alpine

Create a network to connect all services:

Terminal window
# Create network
docker network create code-search-net
# Run services on the network
docker run -d --network code-search-net --name postgres ...
docker run -d --network code-search-net --name redis ...
docker run -d --network code-search-net --name code-search \
-e CS_DATABASE_URL="postgres://codesearch:secret@postgres:5432/codesearch" \
-e CS_REDIS_URL="redis://redis:6379" \
ghcr.io/techquestsdev/code-search:latest

The container includes health check endpoints:

Terminal window
# Liveness
curl http://localhost:8080/health
# Readiness (checks all dependencies)
curl http://localhost:8080/ready

Configure Docker health check:

Terminal window
docker run -d \
--name code-search \
--health-cmd="curl -f http://localhost:8080/health || exit 1" \
--health-interval=30s \
--health-timeout=10s \
--health-retries=3 \
ghcr.io/techquestsdev/code-search:latest

Set resource limits for production:

Terminal window
docker run -d \
--name code-search \
--memory=4g \
--cpus=2 \
ghcr.io/techquestsdev/code-search:latest

Recommended minimums:

  • Memory: 2GB (4GB+ for large codebases)
  • CPU: 2 cores
  • Disk: 10GB + 2x your total repository size

View container logs:

Terminal window
# Follow logs
docker logs -f code-search
# Last 100 lines
docker logs --tail 100 code-search

To update to a new version:

Terminal window
# Pull new image
docker pull ghcr.io/techquestsdev/code-search:latest
# Stop and remove old container
docker stop code-search
docker rm code-search
# Run new container (with same volumes)
docker run -d \
--name code-search \
-v code-search-data:/data \
... \
ghcr.io/techquestsdev/code-search:latest