-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
101 lines (95 loc) · 2.34 KB
/
Copy pathdocker-compose.yml
File metadata and controls
101 lines (95 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# docker-compose.yml (racine oasis/models/crime_predictor/)
version: '3.8'
services:
# MLflow Tracking Server + Backend Store
mlflow:
image: python:3.11-slim
ports:
- "5000:5000"
command: >
bash -c "pip install mlflow psycopg2-binary &&
mlflow server
--backend-store-uri postgresql://mlflow:mlflow@postgres:5432/mlflow_db
--default-artifact-root ./mlruns
--host 0.0.0.0 --port 5000"
volumes:
- mlflow_data:/mlruns
- ./models:/models
depends_on:
- postgres
networks:
- ml_network
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:5000/health"]
interval: 30s
timeout: 10s
retries: 3
# Postgres Backend pour MLflow (persistance expérimentations)
postgres:
image: postgres:15-alpine
environment:
POSTGRES_DB: mlflow_db
POSTGRES_USER: mlflow
POSTGRES_PASSWORD: mlflow
volumes:
- postgres_data:/var/lib/postgresql/data
ports:
- "5432:5432"
networks:
- ml_network
healthcheck:
test: ["CMD-SHELL", "pg_isready -U mlflow -d mlflow_db"]
interval: 10s
timeout: 5s
retries: 5
# API FastAPI Crime Predictor
api:
build: .
ports:
- "8000:8000"
environment:
- MLFLOW_TRACKING_URI=http://mlflow:5000
- MODEL_PATH=/app/models/crime_predictor.pkl
volumes:
- ./models:/app/models
depends_on:
mlflow:
condition: service_healthy
postgres:
condition: service_healthy
networks:
- ml_network
command: >
bash -c "
until curl -f http://mlflow:5000/health; do
echo '⏳ Attente MLflow...';
sleep 5;
done;
uvicorn predict:app --host 0.0.0.0 --port 8000
"
# Training Worker (optionnel - CI/CD)
trainer:
build: .
environment:
- MLFLOW_TRACKING_URI=http://mlflow:5000
volumes:
- ./models:/app/models
depends_on:
- mlflow
- postgres
networks:
- ml_network
command: >
bash -c "
until curl -f http://mlflow:5000/health; do
echo '⏳ Attente MLflow...';
sleep 5;
done;
python train.py --data-url 'https://static.data.gouv.fr/.../delinquance.csv'
"
volumes:
mlflow_data:
postgres_data:
networks:
ml_network:
driver: bridge