> ## Documentation Index
> Fetch the complete documentation index at: https://docs.callintel.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Docker Setup

> Deploy CallIntel with Docker Compose. Deploy the entire CallIntel platform with all microservices using Docker Compose.

## Prerequisites

* Docker Engine 20.10+
* Docker Compose 2.0+
* 4GB RAM minimum
* 20GB disk space

## Architecture

The docker-compose setup includes:

| Service       | Port       | Purpose                     |
| ------------- | ---------- | --------------------------- |
| app           | 8010       | Main API & WebSocket server |
| tele\_mcp     | 8100       | Telegram MCP integration    |
| gmail\_mcp    | 8101       | Gmail MCP integration       |
| whatsapp\_mcp | 8102       | WhatsApp MCP integration    |
| livekit       | 7880, 7881 | LiveKit media server        |
| scheduler     | -          | Background job scheduler    |

## Setup Steps

### 1. Prepare Environment

```bash theme={null}
cp .env.example .env
```

Configure your `.env` file with all required API keys and credentials.

### 2. Build Base Image

```bash theme={null}
docker-compose build base
```

This creates the base image with all common dependencies.

### 3. Build All Services

```bash theme={null}
docker-compose build
```

### 4. Start Services

```bash theme={null}
docker-compose up -d
```

Monitor logs:

```bash theme={null}
docker-compose logs -f
```

Check specific service:

```bash theme={null}
docker-compose logs -f app
```

### 5. Verify Deployment

```bash theme={null}
# Check all services are running
docker-compose ps

# Test API endpoint
curl https://py.callai.rejoicehub.com/health

# View container logs
docker-compose logs app
```

## Service Details

### Main App Service

```yaml theme={null}
services:
  app:
    build:
      context: .
      dockerfile: docker/Dockerfile.app
    ports:
      - "8010:8010"
    environment:
      - PORT=8010
      - Environment=production
    depends_on:
      - base
      - tele_mcp
      - gmail_mcp
    networks:
      - call-agent-network
```

**Key Environment Variables:**

* `PORT`: Application port (default: 8010)
* `Environment`: Set to `production` for production use
* `GEMINI_API_KEY`: Google Gemini API key
* `OPENAI_API_KEY`: OpenAI API key
* `SUPABASE_URL`: Supabase project URL
* `SUPABASE_KEY`: Supabase API key

### MCP Services

#### Telegram MCP (Port 8100)

Handles Telegram integration:

* Message forwarding
* User management
* Async processing

#### Gmail MCP (Port 8101)

Manages Gmail operations:

* Email sending/receiving
* Attachment handling
* OAuth authentication

#### WhatsApp MCP (Port 8102)

WhatsApp integration:

* Message delivery
* Media handling
* Group management

## Scaling

### Horizontal Scaling

```bash theme={null}
# Scale app service to 3 instances
docker-compose up -d --scale app=3
```

### Resource Limits

Edit `docker-compose.yml`:

```yaml theme={null}
services:
  app:
    deploy:
      resources:
        limits:
          cpus: '2'
          memory: 4G
        reservations:
          cpus: '1'
          memory: 2G
```

## Networking

All services communicate via the internal Docker network `call-agent-network`. To expose services externally:

```yaml theme={null}
networks:
  call-agent-network:
    driver: bridge
```

## Data Persistence

### Volumes

```yaml theme={null}
volumes:
  supabase_data:
  postgres_data:
```

Create persistent volumes:

```bash theme={null}
docker volume create callintel-data
```

## Health Checks

Each service includes health checks:

```yaml theme={null}
healthcheck:
  test: ["CMD", "curl", "-f", "https://py.callai.rejoicehub.com/health"]
  interval: 30s
  timeout: 10s
  retries: 3
  start_period: 40s
```

Check service health:

```bash theme={null}
docker-compose exec app curl https://py.callai.rejoicehub.com/health
```

## Troubleshooting

### Port Conflicts

If ports are already in use, modify port mappings in `docker-compose.yml`:

```yaml theme={null}
ports:
  - "8020:8010"  # Map to different host port
```

### Container Won't Start

```bash theme={null}
# Check logs
docker-compose logs app

# Rebuild without cache
docker-compose build --no-cache app

# Remove and restart
docker-compose down
docker-compose up -d
```

### Memory Issues

```bash theme={null}
# Check resource usage
docker stats

# Increase memory limit in docker-compose.yml
# Or increase Docker Desktop memory allocation
```

### Network Issues

```bash theme={null}
# Test network connectivity
docker-compose exec app ping tele_mcp

# Check DNS resolution
docker-compose exec app nslookup tele_mcp
```

## Production Deployment

### Environment Setup

```bash theme={null}
# Use production config
export Environment=production

# Enable security headers
SECURE_HEADERS=true
CORS_ORIGINS=https://yourdomain.com
```

### SSL/TLS

Add reverse proxy (nginx):

```yaml theme={null}
services:
  nginx:
    image: nginx:latest
    ports:
      - "443:443"
      - "80:80"
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf
      - ./certs:/etc/nginx/certs
    depends_on:
      - app
```

### Database Backups

```bash theme={null}
# Backup Supabase data
docker-compose exec supabase pg_dump > backup.sql

# Backup volumes
docker run --rm -v callintel-data:/data \
  -v $(pwd):/backup alpine \
  tar czf /backup/data-backup.tar.gz /data
```

## Monitoring

### Logs

```bash theme={null}
# View all logs
docker-compose logs -f

# View specific service
docker-compose logs -f app

# Filter by time
docker-compose logs -f --since 1h app

# View only errors
docker-compose logs app | grep ERROR
```

### Metrics

```bash theme={null}
# CPU and memory usage
docker stats

# Container inspection
docker-compose ps -q | xargs docker inspect --format='{{.Name}} {{.State.Status}}'
```

## Stopping and Cleanup

```bash theme={null}
# Stop services
docker-compose stop

# Stop and remove containers
docker-compose down

# Remove all volumes (WARNING: deletes data)
docker-compose down -v

# Remove images
docker-compose down --rmi all
```

## Next Steps

<Card title="Configuration" icon="sliders" href="/guides/getting-started/configuration">
  Learn about all configuration options.
</Card>
