CodePilot
Database

Environment Variables

Complete reference for all environment variables required by CodePilot services.

CodePilot uses per-service environment files. Each application (API, worker, web) has its own .env file with service-specific configuration.

Root .env — Docker Compose

Used by docker-compose.yml to configure PostgreSQL and Redis:

VariableDescriptionExample
POSTGRES_USERPostgreSQL usernamecodepilot
POSTGRES_PASSWORDPostgreSQL passwordcodepilot
POSTGRES_DBPostgreSQL database namecodepilot
POSTGRES_PORTPostgreSQL port5432
REDIS_HOSTRedis hostnamelocalhost
REDIS_PORTRedis port6379

.env.api — API Server

VariableDescriptionExample
NODE_ENVEnvironmentdevelopment
PORTAPI server port8080
DATABASE_URLPostgreSQL connection stringpostgresql://codepilot:codepilot@localhost:5432/codepilot
REDIS_HOSTRedis hostlocalhost
REDIS_PORTRedis port6379
ACCESS_TOKEN_SECRETJWT access token secret(random string)
REFRESH_TOKEN_SECRETJWT refresh token secret(random string)
ENCRYPTION_SECRET256-bit hex key for encryption(see below)
SESSION_SECRETSession signing secret(random string)
GITHUB_CLIENT_IDGitHub OAuth App client IDIv23li...
GITHUB_CLIENT_SECRETGitHub OAuth App client secretfbc6b9...
GITHUB_APP_IDGitHub App ID4106749
GITHUB_WEBHOOK_SECRETWebhook signature secret(random string)
GITHUB_PRIVATE_KEYGitHub App RSA private key-----BEGIN RSA PRIVATE KEY-----\n...
OLLAMA_URLOllama API endpointhttp://localhost:11434
OLLAMA_CHAT_MODELModel for chat/code reviewqwen2.5-coder:3b
OLLAMA_EMBED_MODELModel for embeddingsnomic-embed-text
FRONTEND_URLFrontend origin for CORShttp://localhost:3000

.env.worker — Worker

The worker shares most variables with the API:

VariableDescriptionExample
DATABASE_URLPostgreSQL connection string(same as API)
REDIS_HOSTRedis hostlocalhost
REDIS_PORTRedis port6379
ENCRYPTION_SECRET256-bit hex key(same as API)
OLLAMA_URLOllama API endpointhttp://localhost:11434
OLLAMA_CHAT_MODELChat model nameqwen2.5-coder:3b
OLLAMA_EMBED_MODELEmbedding model namenomic-embed-text
GITHUB_APP_IDGitHub App ID(same as API)
GITHUB_PRIVATE_KEYGitHub App private key(same as API)

.env.web — Frontend

VariableDescriptionExample
NEXT_PUBLIC_API_URLBackend API URLhttp://localhost:8080/api
NEXT_PUBLIC_SESSION_COOKIE_NAMESession cookie keycodepilot_session

Generating Secrets

Use openssl to generate secure random strings:

# 256-bit hex key for ENCRYPTION_SECRET
openssl rand -hex 32
# Random string for ACCESS_TOKEN_SECRET, REFRESH_TOKEN_SECRET, SESSION_SECRET
openssl rand -base64 32
# Hex string for GITHUB_WEBHOOK_SECRET
openssl rand -hex 32

Security

Never commit .env files to version control. Add them to .gitignore and use a secrets manager for production deployments.

Docker Networking

Host Configuration

When running services inside Docker containers, hostnames differ from local development:

  • Local development: Use localhost for REDIS_HOST and DATABASE_URL
  • Docker containers: Use Docker service names (postgres, redis-stack)
  • Ollama from Docker: Use host.docker.internal:11434 on Docker Desktop

On this page