# BiRefNet background removal service — installs the published package on the CUDA 12.6 runtime.
# Same CUDA base family as the main ../Dockerfile, but installs rmbg-as-a-service from TestPyPI
# with a plain pip rather than building from the local source tree.
FROM nvidia/cuda:12.6.1-cudnn-runtime-ubuntu24.04

ENV DEBIAN_FRONTEND=noninteractive \
    PYTHONUNBUFFERED=1 \
    PIP_BREAK_SYSTEM_PACKAGES=1 \
    HF_HOME=/app/hf_cache \
    HF_HUB_ENABLE_HF_TRANSFER=1 \
    PORT=8000

# Ubuntu 24.04 ships Python 3.12 (the project requires >=3.12).
RUN apt-get update \
    && apt-get install -y --no-install-recommends python3 python3-pip ca-certificates \
    && rm -rf /var/lib/apt/lists/*

# rmbg-as-a-service from TestPyPI; its deps from real PyPI; CUDA torch from the PyTorch index.
# pip prefers torch's +cu126 build because the local version label outranks the plain wheel.
RUN pip install \
    --index-url https://test.pypi.org/simple/ \
    --extra-index-url https://pypi.org/simple/ \
    --extra-index-url https://download.pytorch.org/whl/cu126 \
    "rmbg-as-a-service==0.0.2" hf-transfer

EXPOSE 8000
CMD ["rmbg-as-a-service"]
