Docker Setup
MangroveAI runs inside Docker using a bundled PostgreSQL service with versioned migrations.
Data Persistence
All data is stored in the Docker volume mangroveai_postgres_data. This volume persists across container restarts and rebuilds.
Safe Rebuild (Preserves Data)
docker compose down
docker compose up -d --build
Dangerous Commands (Deletes All Data)
These commands will permanently delete all conversations, strategies, and backtests.
# NEVER use unless you want a complete reset
docker compose down -v
docker system prune -a --volumes
Backup and Restore
# Backup
docker compose exec postgres pg_dump -U postgres mangrove_db > backup_$(date +%Y%m%d).sql
# Restore
docker compose exec -T postgres psql -U postgres -d mangrove_db < backup_YYYYMMDD.sql
Configuration
Required Environment Variables
Create .env from the template:
cp src/MangroveAI/environment-copy.txt src/MangroveAI/.env
At minimum, set:
OPENAI_API_KEY — Required for AI Copilot
COINAPI_API_KEY — Required for market data
DATABASE_URL — Auto-configured by Docker Compose
Starting Services
# Start all services
docker compose up -d
# Start specific services
docker compose up -d mangrove-app postgres
# View logs
docker compose logs -f mangrove-app
# Check health
curl http://localhost:5001/health
Service Ports
| Service | Port | Description |
|---|
| mangrove-app | 5001 | Flask API backend |
| postgres | 5432 | PostgreSQL database |
| mangrove-admin | 3589 | Developer portal |
| knowledge-base | 8080 | KB FastAPI server |