Skip to main content

Docker Deployment

One-click deployment with Docker Compose Deploy the entire Korad.AI stack with a single command.

Prerequisites​

  • Docker Engine 20.10+
  • Docker Compose 2.0+
  • 2GB RAM minimum (4GB recommended)
  • API keys for at least one LLM provider

Quick Start​

1. Clone Repository​

git clone https://github.com/koradai/bifrost.git
cd bifrost

2. Configure Environment​

# Copy example environment file
cp .env.example .env

# Edit and add your API keys
nano .env

Add at least one provider:

# Anthropic (Claude models)
ANTHROPIC_API_KEY=sk-ant-your-key-here

# OpenAI (GPT models)
OPENAI_API_KEY=sk-proj-your-key-here

# DeepSeek
DEEPSEEK_API_KEY=sk-your-key-here

3. Deploy​

# Start all services
docker-compose up -d

This starts:

  • Optimizer (port 8084) - Main API endpoint
  • Bifrost Gateway (port 8081) - Virtual keys, governance
  • Redis (port 6379) - State store
  • MCP Tools - Built-in tools

4. Verify​

# Check all services are running
docker-compose ps

# Run verification tests
python golden_run.py

Services​

Optimizer (Port 8084)​

The main API endpoint that handles optimization tiers.

# Check health
curl http://localhost:8084/health

# View logs
docker-compose logs -f optimizer

Bifrost Gateway (Port 8081)​

Handles virtual keys, budgets, and rate limits.

# Check health
curl http://localhost:8081/health

# Get virtual keys
curl http://localhost:8081/api/governance/virtual-keys

Redis (Port 6379)​

State store for Vanishing Context.

# Connect to Redis
redis-cli -h localhost -p 6379

# View keys
redis-cli KEYS "*"

Configuration​

Environment Variables​

VariableDescriptionDefault
ANTHROPIC_API_KEYAnthropic API key-
OPENAI_API_KEYOpenAI API key-
DEEPSEEK_API_KEYDeepSeek API key-
GEMINI_API_KEYGoogle Gemini API key-
BRAVE_SEARCH_KEYBrave Search for web_search tool-
PROFIT_MARGINBilling profit multiplier1.5
REDIS_URLRedis connection stringredis://redis:6379/0

Docker Compose Override​

Create docker-compose.override.yml for custom configuration:

services:
optimizer:
environment:
- PROFIT_MARGIN=2.0
deploy:
resources:
limits:
cpus: '2'
memory: 2G

Production Deployment​

1. Use Production Config​

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

2. Set Resource Limits​

services:
optimizer:
deploy:
resources:
limits:
cpus: '4'
memory: 4G
reservations:
cpus: '2'
memory: 2G

3. Enable HTTPS​

Add reverse proxy (nginx/traefik):

services:
nginx:
image: nginx:alpine
ports:
- "443:443"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
- ./ssl:/etc/nginx/ssl

4. Use Managed Services​

For production, consider managed services:

  • Redis: Redis Cloud, AWS ElastiCache
  • Database: Neon PostgreSQL, AWS RDS

Scaling​

Horizontal Scaling​

# Scale optimizer to 3 instances
docker-compose up -d --scale optimizer=3

Add load balancer:

services:
loadbalancer:
image: nginx:alpine
ports:
- "8084:80"
volumes:
- ./nginx-lb.conf:/etc/nginx/nginx.conf

Vertical Scaling​

Increase resource limits:

services:
optimizer:
deploy:
resources:
limits:
cpus: '8'
memory: 8G

Monitoring​

Health Checks​

# Check all services
curl http://localhost:8084/health
curl http://localhost:8081/health
redis-cli ping

Logs​

# All services
docker-compose logs -f

# Specific service
docker-compose logs -f optimizer

# Last 100 lines
docker-compose logs --tail=100 optimizer

Metrics​

# View metrics
curl http://localhost:8081/metrics

Backup​

Redis Data​

# Backup Redis
docker exec korad-redis redis-cli SAVE
docker cp korad-redis:/data/dump.rdb ./backup/

# Restore
docker cp ./backup/dump.rdb korad-redis:/data/dump.rdb

Configuration​

# Backup config
cp config.dev.json backup/
cp .env backup/

Troubleshooting​

Services Won't Start​

# Check for port conflicts
netstat -tulpn | grep -E '8081|8084|6379'

# Check Docker logs
docker-compose logs

High Memory Usage​

# Check resource usage
docker stats

# Clean up
docker system prune -a

Permission Errors​

# Fix data directory permissions
sudo chown -R $USER:$USER data/

Maintenance​

Update Services​

# Pull latest images
docker-compose pull

# Rebuild and restart
docker-compose up -d --build

Clean Up​

# Stop all services
docker-compose down

# Remove volumes
docker-compose down -v

# Clean up unused resources
docker system prune -a

Deploy your AI service provider business in minutes.