# Prometheus backend (FastAPI + YOLO + distance sampling) container. # Weights are baked in and served ONLY through the API — never exposed for # download. Run this on a PRIVATE host (HF Space / Cloud Run / VPS); the public # React dashboard talks to it over HTTPS. FROM python:3.11-slim # System libs: OpenCV runtime + ffmpeg (video jobs). Headless OpenCV needs no GUI libs. RUN apt-get update && apt-get install -y --no-install-recommends \ libglib2.0-0 ffmpeg \ && rm -rf /var/lib/apt/lists/* WORKDIR /app # CPU-only torch — keeps the image ~1.5 GB instead of ~6 GB with CUDA. RUN pip install --no-cache-dir \ torch torchvision --index-url https://download.pytorch.org/whl/cpu # App dependencies (lean: the API set, not the Streamlit/pandas dev extras). RUN pip install --no-cache-dir \ ultralytics opencv-python-headless numpy scipy pyyaml lap pillow \ fastapi "uvicorn[standard]" python-multipart imageio imageio-ffmpeg # Application code + trained weights + (optional) the built dashboard. COPY src ./src COPY api ./api COPY config ./config COPY weights ./weights COPY web ./web # Avoid the OpenMP duplicate-runtime crash; honour the platform's $PORT. ENV KMP_DUPLICATE_LIB_OK=TRUE ENV PORT=8080 EXPOSE 8080 # Shell form so ${PORT} expands (Cloud Run injects PORT; HF Spaces expects 7860). CMD uvicorn api.main:app --host 0.0.0.0 --port ${PORT}