Docker Compose
Development and production Docker Compose configurations for orchestrating all CodePilot services.
CodePilot provides two Docker Compose files — one for development infrastructure and one for the full production stack.
Development (docker-compose.yml)
The development compose file starts only the infrastructure services. Applications run natively on the host for hot reload:
services:
postgres:
image: pgvector/pgvector:pg18
container_name: codepilot_postgres
restart: unless-stopped
environment:
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_INITDB_ARGS: --encoding=UTF8 --locale=C
ports:
- "${POSTGRES_PORT:-5432}:5432"
volumes:
- postgres_data:/var/lib/postgresql
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
interval: 10s
timeout: 5s
retries: 5
networks:
- backend
redis-stack:
image: redis/redis-stack:latest
container_name: codepilot_redis
restart: unless-stopped
ports:
- "${REDIS_PORT:-6379}:6379"
- "${REDIS_STACK_PORT:-8001}:8001"
volumes:
- redis_data:/data
networks:
- backend
volumes:
postgres_data:
driver: local
name: codepilot_postgres_data
redis_data:
driver: local
name: codepilot_redis_data
networks:
backend:
driver: bridge
name: codepilot_backendUsage:
# Start infrastructure
docker compose up -d
# Run apps natively with hot reload
pnpm devProduction (docker-compose.prod.yml)
The production compose file builds and runs all services:
services:
postgres:
# ... (same as dev)
redis-stack:
# ... (same as dev, with healthcheck)
api:
build:
context: .
dockerfile: apps/api/Dockerfile
container_name: codepilot_api
restart: unless-stopped
env_file: .env.api
ports:
- "8080:8080"
depends_on:
postgres:
condition: service_healthy
redis-stack:
condition: service_healthy
worker:
build:
context: .
dockerfile: apps/worker/Dockerfile
container_name: codepilot_worker
restart: unless-stopped
env_file: .env.worker
depends_on:
postgres:
condition: service_healthy
redis-stack:
condition: service_healthy
web:
build:
context: .
dockerfile: apps/web/Dockerfile
container_name: codepilot_web
restart: unless-stopped
env_file: .env.web
ports:
- "3000:3000"
depends_on:
api:
condition: service_startedUsage:
docker compose -f docker-compose.prod.yml up -d --buildServices Overview
| Service | Container | Port | Description |
|---|---|---|---|
| PostgreSQL | codepilot_postgres | 5432 | Database with pgvector |
| Redis | codepilot_redis | 6379 | Job queue backing store |
| API | codepilot_api | 8080 | Express REST API |
| Worker | codepilot_worker | — | Background job processor |
| Web | codepilot_web | 3000 | Next.js frontend |
Health Checks and Dependencies
The production compose uses health checks to ensure services start in the correct order:
- PostgreSQL and Redis start first with health checks
- API and Worker wait for both to be healthy
- Web waits for the API to start
Networking
All services share a backend Docker network, allowing them to communicate using service names:
api → postgres (host: "postgres", port: 5432)
api → redis-stack (host: "redis-stack", port: 6379)
worker → postgres
worker → redis-stack
web → api (host: "api", port: 8080)Ollama Access
Ollama runs on the host machine, not inside Docker. Containers access it via host.docker.internal:11434 on Docker Desktop. Set OLLAMA_URL=http://host.docker.internal:11434 in your .env.api and .env.worker files for production.