# Parakeet ASR seat: parakeet-unified-en-0.6b under NeMo torch, bf16 weights.
# CUDA 12.8 runtime base + a uv-managed venv pinned to the A/B's proven stack
# (torch 2.8 cu128, nemo_toolkit[asr]==3.0.0; the A/B found NeMo 2.7.3 lacks this encoder's
# att_chunk_context_size, so 3.0.0 is a floor, not a preference).
# Weights are NOT baked in: /tank/aimodels/huggingface is bind-mounted read-only (see compose).
FROM nvidia/cuda:12.8.1-base-ubuntu24.04

ENV DEBIAN_FRONTEND=noninteractive \
    PIP_DISABLE_PIP_VERSION_CHECK=1 \
    PYTHONUNBUFFERED=1 \
    HF_HUB_OFFLINE=1

RUN apt-get update && apt-get install -y --no-install-recommends \
      python3 python3-venv python3-pip wget libsndfile1 ca-certificates \
    && rm -rf /var/lib/apt/lists/*

RUN python3 -m venv /opt/venv \
    && /opt/venv/bin/pip install -q uv \
    && UV_LINK_MODE=copy /opt/venv/bin/uv pip install -q --python /opt/venv/bin/python \
         --index-url https://download.pytorch.org/whl/cu128 \
         --extra-index-url https://pypi.org/simple \
         "torch==2.8.*" "torchaudio==2.8.*" "nemo_toolkit[asr]==3.0.0" \
         fastapi "uvicorn==0.53.0" python-multipart soundfile \
    && /opt/venv/bin/python -c "import nemo, torch; print('nemo', nemo.__version__, 'torch', torch.__version__, 'cuda_ok', torch.cuda.is_available())"

WORKDIR /app
COPY app.py /app/app.py

# The seat's only writable need is NeMo/HF scratch; keep it off the rootfs surprises.
ENV HOME=/tmp
EXPOSE 8000
# --http h11: the [standard] extra pulls httptools, and httptools 0.8.0 writes a NUL into the
# status line ("HTTP/1.1 200\x00OK") that h11/httpx reject. uvicorn auto-picks httptools when
# importable, so it must stay UNinstalled and the flag must stay explicit. See README.
CMD ["/opt/venv/bin/uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000", "--http", "h11"]
