animetix-web / deploy /Dockerfile.dataflow
MissawB's picture
Upload folder using huggingface_hub (part 3)
488addb verified
Raw History Blame Contribute Delete
2.44 kB
# --- 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"]