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:
| Variable | Description | Example |
|---|---|---|
POSTGRES_USER | PostgreSQL username | codepilot |
POSTGRES_PASSWORD | PostgreSQL password | codepilot |
POSTGRES_DB | PostgreSQL database name | codepilot |
POSTGRES_PORT | PostgreSQL port | 5432 |
REDIS_HOST | Redis hostname | localhost |
REDIS_PORT | Redis port | 6379 |
.env.api — API Server
| Variable | Description | Example |
|---|---|---|
NODE_ENV | Environment | development |
PORT | API server port | 8080 |
DATABASE_URL | PostgreSQL connection string | postgresql://codepilot:codepilot@localhost:5432/codepilot |
REDIS_HOST | Redis host | localhost |
REDIS_PORT | Redis port | 6379 |
ACCESS_TOKEN_SECRET | JWT access token secret | (random string) |
REFRESH_TOKEN_SECRET | JWT refresh token secret | (random string) |
ENCRYPTION_SECRET | 256-bit hex key for encryption | (see below) |
SESSION_SECRET | Session signing secret | (random string) |
GITHUB_CLIENT_ID | GitHub OAuth App client ID | Iv23li... |
GITHUB_CLIENT_SECRET | GitHub OAuth App client secret | fbc6b9... |
GITHUB_APP_ID | GitHub App ID | 4106749 |
GITHUB_WEBHOOK_SECRET | Webhook signature secret | (random string) |
GITHUB_PRIVATE_KEY | GitHub App RSA private key | -----BEGIN RSA PRIVATE KEY-----\n... |
OLLAMA_URL | Ollama API endpoint | http://localhost:11434 |
OLLAMA_CHAT_MODEL | Model for chat/code review | qwen2.5-coder:3b |
OLLAMA_EMBED_MODEL | Model for embeddings | nomic-embed-text |
FRONTEND_URL | Frontend origin for CORS | http://localhost:3000 |
.env.worker — Worker
The worker shares most variables with the API:
| Variable | Description | Example |
|---|---|---|
DATABASE_URL | PostgreSQL connection string | (same as API) |
REDIS_HOST | Redis host | localhost |
REDIS_PORT | Redis port | 6379 |
ENCRYPTION_SECRET | 256-bit hex key | (same as API) |
OLLAMA_URL | Ollama API endpoint | http://localhost:11434 |
OLLAMA_CHAT_MODEL | Chat model name | qwen2.5-coder:3b |
OLLAMA_EMBED_MODEL | Embedding model name | nomic-embed-text |
GITHUB_APP_ID | GitHub App ID | (same as API) |
GITHUB_PRIVATE_KEY | GitHub App private key | (same as API) |
.env.web — Frontend
| Variable | Description | Example |
|---|---|---|
NEXT_PUBLIC_API_URL | Backend API URL | http://localhost:8080/api |
NEXT_PUBLIC_SESSION_COOKIE_NAME | Session cookie key | codepilot_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 32Security
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
localhostforREDIS_HOSTandDATABASE_URL - Docker containers: Use Docker service names (
postgres,redis-stack) - Ollama from Docker: Use
host.docker.internal:11434on Docker Desktop