This guide explains how to deploy the Agentic AI system in production.
- Docker & Docker Compose installed
- Domain name (for HTTPS)
- SSL certificates (Let's Encrypt recommended)
- At least 4GB RAM, 2 CPU cores
- API keys for LLM providers
- Copy environment file:
cp .env.example .env- Edit .env file:
- Add your API keys (OpenAI, Anthropic, etc.)
- Set database credentials
- Configure Redis and other services
- Start all services:
docker-compose up -d- Check health:
curl http://localhost/health- Access services:
- API: http://localhost (port 80)
- API Docs: http://localhost/docs
- Grafana: http://localhost:3000 (admin/admin)
- Prometheus: http://localhost:9090
- RabbitMQ: http://localhost:15672 (guest/guest)
# Set to production
APP_ENV=production
APP_DEBUG=false
# Generate secure keys
SECRET_KEY=$(openssl rand -hex 32)
JWT_SECRET_KEY=$(openssl rand -hex 32)
# Set real database credentials
POSTGRES_PASSWORD=$(openssl rand -hex 16)
# Add real API keys
OPENAI_API_KEY=sk-your-real-key
ANTHROPIC_API_KEY=sk-ant-your-real-keyOption A: Let's Encrypt (Recommended)
# Install certbot
apt-get install certbot python3-certbot-nginx
# Get certificate
certbot --nginx -d yourdomain.com -d www.yourdomain.com
# Auto-renewal
certbot renew --dry-runOption B: Custom Certificate
# Place certificates in nginx/ssl/
mkdir -p nginx/ssl
cp your-cert.pem nginx/ssl/cert.pem
cp your-key.pem nginx/ssl/key.pem
# Update nginx/conf.d/default.conf
# Uncomment SSL configuration lines# Initialize database
docker-compose exec api alembic upgrade head
# Create admin user (implement in code)
docker-compose exec api python scripts/create_admin.py# Build images
docker-compose build --no-cache
# Start services
docker-compose up -d
# View logs
docker-compose logs -f api
# Check status
docker-compose ps# Health check
curl https://yourdomain.com/health
# Test authentication
curl -X POST https://yourdomain.com/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"test@example.com","password":"password"}'
# View metrics
curl https://yourdomain.com/metrics| Service | URL | Credentials |
|---|---|---|
| API | https://yourdomain.com | - |
| API Docs | https://yourdomain.com/docs | - |
| Grafana | https://yourdomain.com:3000 | admin/admin |
| Prometheus | https://yourdomain.com:9090 | - |
| RabbitMQ | https://yourdomain.com:15672 | guest/guest |
Access: http://localhost:9090
Key metrics:
fastapi_requests_total- Total requestsfastapi_request_duration_seconds- Request latencyprocess_cpu_seconds_total- CPU usageprocess_resident_memory_bytes- Memory usage
Access: http://localhost:3000
- Login with admin/admin
- Add Prometheus datasource: http://prometheus:9090
- Import dashboards from monitoring/grafana/dashboards/
# View API logs
docker-compose logs -f api
# View Nginx logs
docker-compose logs -f nginx
# View worker logs
docker-compose logs -f worker
# View all logs
docker-compose logs -f# docker-compose.yml
api:
deploy:
replicas: 4 # Multiple API instances
worker:
deploy:
replicas: 2 # Multiple workersservices:
api:
deploy:
resources:
limits:
cpus: '2'
memory: 4G
reservations:
cpus: '1'
memory: 2G# Backup
docker-compose exec postgres pg_dump -U agenticai agenticai_db > backup.sql
# Restore
docker-compose exec -T postgres psql -U agenticai agenticai_db < backup.sql# Backup ChromaDB
docker cp agenticai-chromadb:/chroma/chroma ./backups/chroma_$(date +%Y%m%d)# Check logs
docker-compose logs api
# Restart service
docker-compose restart api
# Rebuild
docker-compose up -d --build api# Check PostgreSQL
docker-compose exec postgres pg_isready
# Check connection from API
docker-compose exec api python -c "from src.api.database import init_db; import asyncio; asyncio.run(init_db())"# Check Redis
docker-compose exec redis redis-cli ping
# Test connection
docker-compose exec api python -c "import redis; r=redis.from_url('redis://redis:6379/0'); print(r.ping())"- Change default passwords
- Enable HTTPS
- Configure firewall
- Set rate limits
- Enable CORS restrictions
- Regular security updates
- Monitor access logs
- Backup encryption keys
- Enable 2FA for admin
- Set up intrusion detection
-
Database Connection Pooling:
- Adjust POOL_SIZE in .env
- Monitor connection usage
-
Redis Memory:
- Set maxmemory policy
- Monitor memory usage
-
Worker Concurrency:
- Adjust Celery concurrency
- Monitor task queue length
-
API Workers:
- Use multiple Uvicorn workers
- Enable worker timeout
# Pull latest code
git pull
# Rebuild images
docker-compose build --no-cache
# Restart services
docker-compose up -d
# Run migrations
docker-compose exec api alembic upgrade head# Update requirements.txt
pip-compile requirements.in
# Rebuild images
docker-compose build --no-cacheFor issues or questions:
- Check logs:
docker-compose logs -f - Review documentation
- Contact support team
Phase 1 Complete! ✅
Next: Phase 2 - Infrastructure components (CI/CD, Database models, Security hardening)