From 44163bfb983164775ea1aa8f7090084f57314c12 Mon Sep 17 00:00:00 2001 From: Valentin Date: Tue, 22 Sep 2026 15:04:21 +0200 Subject: [PATCH] fix(ml): corrige le build MLflow (psycopg2), le garde-fou Makefile, la doc et la fuite de mot de passe --- Makefile | 2 ++ docs/architecture/10-infra.md | 2 +- ml/Dockerfile | 2 +- ml/docker-compose.mlflow.yml | 11 +++++------ 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index fe60e50..63d0ea5 100644 --- a/Makefile +++ b/Makefile @@ -20,6 +20,8 @@ PG_USER := $(or $(strip $(call env-val,POSTGRES_USER)),enervision) PG_PASSWORD := $(or $(strip $(call env-val,POSTGRES_PASSWORD)),change_me) PG_DB := $(or $(strip $(call env-val,POSTGRES_DB)),enervision) PG_PORT := $(or $(strip $(call env-val,POSTGRES_PORT)),5433) +ml-env-val = $(shell sed -n 's/^$(1)=//p' ml/.env 2>/dev/null | tail -1) +ML_ENV_DB_PASSWORD := $(call ml-env-val,MLFLOW_DB_PASSWORD) AIRFLOW_PORT := $(or $(strip $(call env-val,AIRFLOW_PORT)),8080) MAILPIT_UI_PORT := $(or $(strip $(call env-val,MAILPIT_UI_PORT)),8025) ML_DATABASE_URL ?= postgresql+psycopg://$(PG_USER):$(PG_PASSWORD)@localhost:$(PG_PORT)/$(PG_DB) diff --git a/docs/architecture/10-infra.md b/docs/architecture/10-infra.md index a9d9c0e..a0e977f 100644 --- a/docs/architecture/10-infra.md +++ b/docs/architecture/10-infra.md @@ -155,7 +155,7 @@ du `docker-compose.yml` principal (réseau, volumes et démarrage séparés). | Service | Image | Points notables | |---|---|---| -| `mlflow-db` | `postgres:16` | Stocke le tracking store MLflow. Mot de passe obligatoire via `MLFLOW_DB_PASSWORD` | +| `mlflow-db` | `postgres:17` | Stocke le tracking store MLflow. Mot de passe obligatoire via `MLFLOW_DB_PASSWORD` | | `mlflow` | Construite depuis `ml/` | Expose l'UI et l'API MLflow sur `127.0.0.1:5000`. Artefacts sur volume `mlflow-artifacts`, tracking store sur `mlflow-db` | Portée actuelle : environnement de tracking et de registre de modèles pour le développement diff --git a/ml/Dockerfile b/ml/Dockerfile index bcd1706..070b752 100644 --- a/ml/Dockerfile +++ b/ml/Dockerfile @@ -1,5 +1,5 @@ FROM python:3.14-slim -RUN pip install --no-cache-dir --only-binary :all: mlflow==3.16.1 psycopg2-binary==2.9.10 +RUN pip install --no-cache-dir --only-binary :all: mlflow==3.16.1 psycopg2-binary==2.9.13 RUN useradd --create-home --uid 1000 mlflow \ && mkdir /mlartifacts \ && chown mlflow /mlartifacts diff --git a/ml/docker-compose.mlflow.yml b/ml/docker-compose.mlflow.yml index 78cc5de..92fafbf 100644 --- a/ml/docker-compose.mlflow.yml +++ b/ml/docker-compose.mlflow.yml @@ -21,12 +21,11 @@ services: - "127.0.0.1:5000:5000" volumes: - mlflow-artifacts:/mlartifacts - command: > - mlflow server - --host 0.0.0.0 --port 5000 - --backend-store-uri postgresql://mlflow:${MLFLOW_DB_PASSWORD}@mlflow-db:5432/mlflow - --artifacts-destination /mlartifacts - --serve-artifacts + environment: + MLFLOW_DB_PASSWORD: ${MLFLOW_DB_PASSWORD} + entrypoint: [ "/bin/sh", "-c" ] + command: + - exec mlflow server --host 0.0.0.0 --port 5000 --backend-store-uri "postgresql://mlflow:$$MLFLOW_DB_PASSWORD@mlflow-db:5432/mlflow" --artifacts-destination /mlartifacts --serve-artifacts volumes: mlflow-db-data: