MLflow Tracking Server¶
Custom MLflow Docker image for TradAI platform with PostgreSQL and S3 support.
Features¶
- Based on official
ghcr.io/mlflow/mlflow:v2.16.2 - PostgreSQL backend store support (psycopg2 included)
- S3 artifact storage support (boto3 included)
- Non-root user for security
- Health check endpoint
- Production-ready with gunicorn
Quick Start¶
Development (Local Artifacts)¶
Production (S3 Artifacts)¶
export MLFLOW_BACKEND_STORE_URI="postgresql://user:pass@host:5432/mlflow"
export MLFLOW_DEFAULT_ARTIFACT_ROOT="s3://tradai-mlflow-artifacts/experiments"
docker compose --profile mlflow up
Environment Variables¶
| Variable | Default | Description |
|---|---|---|
MLFLOW_HOST | 0.0.0.0 | Server bind host |
MLFLOW_PORT | 5000 | Server port |
MLFLOW_WORKERS | 2 | Gunicorn workers |
MLFLOW_BACKEND_STORE_URI | sqlite:///mlflow/mlflow.db | Database URI |
MLFLOW_DEFAULT_ARTIFACT_ROOT | /mlflow/artifacts | Artifact storage path |
S3 Artifact Configuration¶
For S3 artifacts, ensure AWS credentials are available:
export AWS_ACCESS_KEY_ID=xxx
export AWS_SECRET_ACCESS_KEY=xxx
export AWS_DEFAULT_REGION=eu-central-1
export MLFLOW_DEFAULT_ARTIFACT_ROOT=s3://your-bucket/mlflow
Authentication¶
MLflow supports HTTP Basic Authentication for production deployments.
Option 1: Built-in Auth (MLflow 2.5+)¶
Set environment variables in services/mlflow/.env:
Option 2: Reverse Proxy Auth¶
For production, use nginx/ALB with authentication in front of MLflow.
Client Configuration¶
Services connect using credentials from .env:
from tradai.common.mlflow_adapter import MLflowAdapter
adapter = MLflowAdapter(
base_url="https://mlflow.tradai.example.com",
username=os.getenv("MLFLOW_TRACKING_USERNAME"),
password=os.getenv("MLFLOW_TRACKING_PASSWORD"),
)
Or set environment variables:
export MLFLOW_TRACKING_URI=https://mlflow.tradai.example.com
export MLFLOW_TRACKING_USERNAME=admin
export MLFLOW_TRACKING_PASSWORD=your-password
Health Check¶
Build Locally¶
Integration with TradAI Services¶
Services connect to MLflow via MLFLOW_TRACKING_URI:
The MLflowAdapter in tradai-common handles connection and experiment logging.