CodePilot
Deployment

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:

docker-compose.yml
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_backend

Usage:

# Start infrastructure
docker compose up -d

# Run apps natively with hot reload
pnpm dev

Production (docker-compose.prod.yml)

The production compose file builds and runs all services:

docker-compose.prod.yml
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_started

Usage:

docker compose -f docker-compose.prod.yml up -d --build

Services Overview

ServiceContainerPortDescription
PostgreSQLcodepilot_postgres5432Database with pgvector
Rediscodepilot_redis6379Job queue backing store
APIcodepilot_api8080Express REST API
Workercodepilot_workerBackground job processor
Webcodepilot_web3000Next.js frontend

Health Checks and Dependencies

The production compose uses health checks to ensure services start in the correct order:

  1. PostgreSQL and Redis start first with health checks
  2. API and Worker wait for both to be healthy
  3. 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.

On this page