# syntax=docker/dockerfile:1.6
#
# Parakeet-TDT ASR via sherpa-onnx (ONNX Runtime + CUDA).
#
# We own this whole image — not forked from an upstream wrapper. ~70 MB of
# application layer over the CUDA+cuDNN runtime base.

ARG CUDA_BASE=nvidia/cuda:12.8.0-cudnn-runtime-ubuntu22.04
FROM ${CUDA_BASE}

ENV DEBIAN_FRONTEND=noninteractive \
    PIP_ROOT_USER_ACTION=ignore \
    PYTHONUNBUFFERED=1 \
    PATH="/opt/venv/bin:${PATH}"

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

RUN pip install --no-cache-dir \
        fastapi \
        'uvicorn[standard]' \
        python-multipart \
        soundfile \
        numpy \
 && pip install --no-cache-dir \
        sherpa-onnx==1.12.39+cuda12.cudnn9 \
        -f https://k2-fsa.github.io/sherpa/onnx/cuda.html

WORKDIR /app
COPY app.py /app/app.py
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh

EXPOSE 8000
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
