FROM python:3.11-slim

# opencv-python-headless needs libgl/libglib at runtime
RUN apt-get update && apt-get install -y --no-install-recommends \
    libgl1 libglib2.0-0 && rm -rf /var/lib/apt/lists/*

WORKDIR /srv

COPY requirements.txt .
# CPU-only torch wheels
RUN pip install --no-cache-dir --extra-index-url https://download.pytorch.org/whl/cpu \
    -r requirements.txt

COPY . .

ENV DATA_DIR=/data HOST=0.0.0.0 PORT=8001
EXPOSE 8001
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8001"]
