version: "3.9" # ── Local development compose ────────────────────────────────────────────────── # Mirrors the production container as closely as possible while making # local iteration fast: # - Source is bind-mounted so code changes are reflected without rebuilds. # - The model artifact volume persists trained models across container restarts. # - Prometheus and a minimal Grafana are included so you can observe the # service locally without a cloud account. # # Usage: # docker compose up --build # first run # docker compose up # subsequent runs (cache hit) # docker compose down -v # tear down including volumes services: # ── ML API ──────────────────────────────────────────────────────────────── api: build: context: . target: runtime args: MODEL_VERSION: "1.0.0-dev" image: ml-inference-api:dev container_name: ml_api environment: - MODEL_VERSION=1.0.0-dev - PYTHONUNBUFFERED=1 ports: - "8000:8000" volumes: # Bind-mount source for hot-reload during development. - ./api:/app/api:ro - ./model:/app/model:ro healthcheck: test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')"] interval: 30s timeout: 5s retries: 3 start_period: 15s restart: unless-stopped networks: - ml_net # ── Prometheus ───────────────────────────────────────────────────────────── prometheus: image: prom/prometheus:v2.53.0 container_name: ml_prometheus ports: - "9090:9090" volumes: - ./deploy/prometheus.yml:/etc/prometheus/prometheus.yml:ro - prometheus_data:/prometheus command: - "--config.file=/etc/prometheus/prometheus.yml" - "--storage.tsdb.path=/prometheus" - "--web.console.libraries=/usr/share/prometheus/console_libraries" - "--web.console.templates=/usr/share/prometheus/consoles" networks: - ml_net # ── Grafana ──────────────────────────────────────────────────────────────── grafana: image: grafana/grafana:11.1.0 container_name: ml_grafana ports: - "3000:3000" environment: - GF_SECURITY_ADMIN_PASSWORD=admin - GF_USERS_ALLOW_SIGN_UP=false volumes: - grafana_data:/var/lib/grafana depends_on: - prometheus networks: - ml_net volumes: prometheus_data: grafana_data: networks: ml_net: driver: bridge