Spaces:
Running
Running
| # --- Stage 1: Get Python Flex Template Launcher Binary --- | |
| # `:latest` est la forme recommandée par Google pour ce launcher. Pour une build | |
| # 100 % reproductible, l'épingler par digest : | |
| # docker pull gcr.io/dataflow-templates-base/python3-template-launcher-base:latest | |
| # docker inspect --format='{{index .RepoDigests 0}}' <image> | |
| # puis remplacer `:latest` par `@sha256:<digest>`. (Le SDK Beam, lui, est déjà épinglé.) | |
| FROM gcr.io/dataflow-templates-base/python3-template-launcher-base:latest AS launcher | |
| # --- Stage 2: Build Application Image --- | |
| FROM apache/beam_python3.12_sdk:2.74.0 | |
| # Copy Flex Template launcher binary | |
| COPY --from=launcher /opt/google/dataflow/python_template_launcher /opt/google/dataflow/python_template_launcher | |
| # Set working directory | |
| WORKDIR /template | |
| # Install system dependencies | |
| USER root | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| libpq-dev \ | |
| gcc \ | |
| libsndfile1 \ | |
| ffmpeg \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy requirements.txt | |
| COPY requirements.txt ./ | |
| # Install pinned Python deps. beautifulsoup4 (==4.12.3) est déjà dans requirements.txt : | |
| # pas de réinstallation séparée non épinglée (build reproductible). | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # ultralytics pulls the GUI opencv-python (needs libGL) next to opencv-python-headless; | |
| # both own the same `cv2` files, so remove both then reinstall only headless. | |
| RUN pip uninstall -y opencv-python opencv-python-headless \ | |
| && pip install --no-cache-dir "$(grep -E '^opencv-python-headless==' requirements.txt)" | |
| # Copy backend codebase | |
| COPY backend/ ./backend/ | |
| # Configure Python search path | |
| ENV PYTHONPATH="/template/backend:/template/backend/api:$PYTHONPATH" | |
| # Specify Pipeline Entrypoint | |
| # Une image Flex Template = un pipeline (convention Dataflow) ; ce projet n'a qu'un | |
| # seul pipeline Beam (lore_ingestion_beam). Ce n'est donc pas un "figement" subi. | |
| ENV FLEX_TEMPLATE_PYTHON_PY_FILE=/template/backend/pipeline/mlops/lore_ingestion_beam.py | |
| # Pas de HEALTHCHECK : ce conteneur est un worker Dataflow Flex Template, orchestré | |
| # et supervisé par le runner Dataflow — le HEALTHCHECK Docker n'est pas utilisé pour | |
| # ce type d'image (il n'aurait aucun effet). | |
| ENTRYPOINT ["/opt/google/dataflow/python_template_launcher"] | |