Spaces:
Build error
Build error
File size: 2,442 Bytes
08f24b1 488addb 08f24b1 c3a8f02 08f24b1 d9f4063 3a6bd24 d9f4063 08f24b1 18629e6 08f24b1 | 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 | # --- Stage 1: Get Python Flex Template Launcher Binary ---
# Pin l'image par digest sha256 pour des builds 100 % reproductibles (audit dette 2026-07-22).
FROM gcr.io/dataflow-templates-base/python3-template-launcher-base@sha256:d84f2b1d3d666d3a8a30689b2fb1e36780c108c49e1eefbfd6796c9c6ec543ab AS launcher
# --- Stage 2: Build Application Image ---
FROM apache/beam_python3.12_sdk:2.75.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/*
# Dataflow lockfile = web stack (the DoFns boot the full Django app) + Beam.
# CPU-only workers: pre-install torch from the PyTorch CPU index so the
# lockfile's `torch==` pin is satisfied by the +cpu wheel (no CUDA wheels).
COPY requirements-dataflow.txt ./
# hadolint ignore=DL3013
RUN pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cpu \
"$(grep -E '^torch==' requirements-dataflow.txt)" \
&& pip install --no-cache-dir -r requirements-dataflow.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
# Redescendre de root pour l'exécution (audit dette 2026-07-11). Les étapes apt/pip
# ci-dessus exigent root ; à l'exécution, le launcher et le worker harness ne font
# que lire /template et les site-packages. NOTE : non vérifié contre une soumission
# Dataflow réelle — si le runner refuse un Flex Template non-root, retirer ce bloc.
RUN useradd --create-home --uid 1000 appuser && chown -R appuser /template
USER appuser
# 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"]
|