FROM python:3.12-slim

WORKDIR /app
COPY requirements/base.txt /tmp/requirements.txt
RUN apt-get update \
    && apt-get install -y --no-install-recommends libmagic1 ffmpeg \
    && rm -rf /var/lib/apt/lists/* \
    && pip install --no-cache-dir -r /tmp/requirements.txt

# Build-time guard: the rep_content video pipeline (apps/rep/content/tasks.py)
# shells out to ffprobe + ffmpeg. If apt silently dropped the package (mirror
# transient, source change, etc.) the worker would still start but every
# transcode would land the row in QUEUED forever — fail loudly *here* instead.
RUN command -v ffmpeg >/dev/null \
    && command -v ffprobe >/dev/null \
    && ffmpeg  -hide_banner -version | head -1 \
    && ffprobe -hide_banner -version | head -1

COPY . .
CMD ["celery", "-A", "config", "worker", "-l", "info"]
