This guide will help you deploy MetabolicAI to popular cloud platforms and run it in production environments. These instructions assume you have basic familiarity with the platform you choose.
git clone https://github.com/furqanagwan/metabolicai.git
cd metabolicai
cp .env.example .env
# Edit .env to set your API_KEY
docker-compose up --buildgit clone https://github.com/furqanagwan/metabolicai.git
cd metabolicai
cp .env.example .env
# Create virtual environment
python3 -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Start the server
uvicorn app.main:app --reloadAccess Points:
- 🌐 API: http://localhost:8000
- 📖 Docs: http://localhost:8000/docs
- ❤️ Health: http://localhost:8000/health
Before you can log entries or get predictions, register a user profile:
curl -X POST "http://localhost:8000/user" \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/json" \
-d '{"user_id": "demo", "age": 30, "gender": "male"}'After this, you can log entries with POST /entry or PATCH /entry as usual.
The included Dockerfile provides:
- ✅ Multi-stage build – Smaller final image (~150MB)
- ✅ Non-root user – Enhanced security
- ✅ Health check – Built-in
/healthendpoint - ✅ Python 3.11 – Latest stable version
Build and test locally:
docker build -t metabolicai .
docker run -d -p 8000:8000 \
-v $(pwd)/data:/app/data \
-v $(pwd)/models:/app/models \
-e API_KEY=your-secret-key \
metabolicai
# Verify health
curl http://localhost:8000/health-
Build and push to Azure Container Registry:
az acr build --registry <your-acr-name> --image metabolicai:latest .
-
Create Container App:
az containerapp create \ --name metabolicai \ --resource-group <your-rg> \ --image <your-acr>.azurecr.io/metabolicai:latest \ --target-port 8000 \ --ingress external \ --env-vars API_KEY=your-secret-key
-
Test the endpoint:
curl https://<your-app>.azurecontainerapps.io/health
💡 Tip: Use Azure Key Vault for managing secrets in production.
-
Push to ECR:
aws ecr get-login-password --region <region> | docker login --username AWS --password-stdin <account>.dkr.ecr.<region>.amazonaws.com docker build -t metabolicai . docker tag metabolicai:latest <account>.dkr.ecr.<region>.amazonaws.com/metabolicai:latest docker push <account>.dkr.ecr.<region>.amazonaws.com/metabolicai:latest
-
Create App Runner service:
- Go to AWS App Runner console
- Select "Container registry" → ECR
- Configure port 8000
- Add environment variable:
API_KEY - Deploy
- Create ECS cluster and task definition
- Configure container with:
- Image: Your ECR image
- Port mapping: 8000
- Health check:
curl -f http://localhost:8000/health || exit 1 - Environment:
API_KEY
- Create service with Application Load Balancer
# Build and push
gcloud builds submit --tag gcr.io/<project-id>/metabolicai
# Deploy
gcloud run deploy metabolicai \
--image gcr.io/<project-id>/metabolicai \
--platform managed \
--port 8000 \
--allow-unauthenticated \
--set-env-vars API_KEY=your-secret-key
# Test
curl https://metabolicai-<hash>.run.app/health💡 Tip: Use Secret Manager for the API key in production.
-
Provision a VM (Ubuntu 22.04 recommended)
-
Install Docker:
sudo apt update && sudo apt install -y docker.io docker-compose sudo usermod -aG docker $USER
-
Clone and run:
git clone https://github.com/furqanagwan/metabolicai.git cd metabolicai cp .env.example .env nano .env # Set your API_KEY docker-compose up --build -d
-
Set up reverse proxy (nginx + HTTPS):
sudo apt install -y nginx certbot python3-certbot-nginx # Configure nginx sudo nano /etc/nginx/sites-available/metabolicaiserver { listen 80; server_name your-domain.com; location / { proxy_pass http://localhost:8000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } }
sudo ln -s /etc/nginx/sites-available/metabolicai /etc/nginx/sites-enabled/ sudo certbot --nginx -d your-domain.com
-
Enable firewall:
sudo ufw allow 80 sudo ufw allow 443 sudo ufw enable
| Area | Recommendation |
|---|---|
| Secrets | Use cloud secret managers (AWS Secrets Manager, Azure Key Vault, GCP Secret Manager) |
| HTTPS | Always use TLS in production (built-in on cloud platforms, or use Caddy/nginx) |
| Monitoring | Enable container logs and set up alerts for health check failures |
| Database | Consider PostgreSQL for production scale (update app/database.py) |
| Backups | Mount data/ and models/ to persistent storage with backups |
| Rate Limiting | Add rate limiting via reverse proxy or API gateway |
| CORS | Restrict CORS_ORIGINS to your frontend domains |
All deployment platforms support health checks. MetabolicAI exposes:
GET /health
Response:
{
"status": "healthy",
"version": "1.0.0"
}Configure your platform's health check to hit this endpoint every 30 seconds.
Contributions and questions are always welcome!