This guide will help you set up MXGo using Docker for easy self-hosting.
MXGo uses a simplified Docker architecture with health checks and dependency management built into docker-compose.yml.
- Docker Desktop (includes Docker Compose)
- At least 4GB of RAM available for Docker
- At least 10GB of free disk space
# Clone the repository
git clone <your-repo-url>
cd mxgo
# Run the setup script
chmod +x scripts/setup-local.sh
./scripts/setup-local.shQuick Setup:
# Copy the template
cp .env.example .env
# Edit with your values
nano .env # or your preferred editorRequired Configuration:
X_API_KEY- Set to a secure random string (32+ characters)LITELLM_DEFAULT_MODEL_GROUP- Default AI model group (usually "gpt-4")- AWS SES credentials for email sending (if needed)
Docker Defaults: The Docker setup provides secure defaults for all infrastructure services:
- PostgreSQL, Redis, RabbitMQ are preconfigured
- Only external services need your API keys
📚 Complete Reference: See ENV_VARIABLES.md for all configuration options.
Edit the model.config.toml file to configure your AI models:
# Example for OpenAI
[[model]]
model_name = "gpt-4"
litellm_params = { model = "gpt-4", api_key = "your_openai_api_key_here" }
# Example for Azure OpenAI
[[model]]
model_name = "azure-gpt-4"
litellm_params = {
model = "azure/gpt-4",
api_key = "your_azure_openai_api_key_here",
base_url = "https://your-resource.openai.azure.com/",
api_version = "2023-05-15"
}# Start all services
./scripts/start-local.sh
# Or manually with docker-compose
docker-compose up --buildThis will start:
- PostgreSQL - Database (port 5432)
- Redis - Cache and session storage (port 6379)
- RabbitMQ - Message queue (port 5672, management UI on port 15672)
- API Server - Main application (port 8000)
- Worker - Background task processor
- Scheduler - Scheduled task manager (depends on worker health)
The services start in order based on health checks, with the scheduler waiting for the worker to be healthy before starting.
Once all services are running:
- API Health Check: Visit http://localhost:8000/health
- RabbitMQ Management: Visit http://localhost:15672 (guest/guest)
- API Documentation: Visit http://localhost:8000/docs
- Use external databases: Evaluate if it's okay to run PostgreSQL and Redis in containers as per task workload, else use external services.
- Configure HTTPS: Use a reverse proxy like nginx or Traefik
- Set resource limits: Configure Docker memory and CPU limits
- Enable monitoring: Set up logging and monitoring
- Backup strategy: Implement database backups
# docker-compose.prod.yml
version: "3.9"
services:
api_server:
# ... same configuration but with:
restart: always
deploy:
resources:
limits:
memory: 2G
cpus: '1.0'
worker:
restart: always
deploy:
replicas: 2 # Scale workers based on load
resources:
limits:
memory: 1G
cpus: '0.5'- Port conflicts: Change ports in
.envif default ports are in use - Out of memory: Increase Docker Desktop memory allocation
- Permission errors: Ensure Docker has necessary permissions
- Database connection fails: Wait for all services to fully start
# View logs for specific service
docker-compose logs api_server
docker-compose logs worker
docker-compose logs scheduler
# Follow logs in real-time
docker-compose logs -f api_server# Access running container
docker exec -it api_server bash
docker exec -it postgres psql -U mxgo -d mxgo
# Check service status
docker-compose ps# Stop all services and remove data
docker-compose down -v
# Remove all images and rebuild
docker-compose down --rmi all -v
docker-compose up --buildAll services include health checks:
- API Server:
curl http://localhost:8000/health - PostgreSQL: Built-in
pg_isready - Redis: Built-in ping
- RabbitMQ: Built-in diagnostics