FROM nvidia/cuda:13.0.3-runtime-ubuntu24.04

# Avoid interactive prompts during package installation
ENV DEBIAN_FRONTEND=noninteractive

# Install Python and system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
    python3 \
    python3-pip \
    python3-dev \
    git \
    libsndfile1 \
    ffmpeg \
    && rm -rf /var/lib/apt/lists/*

# Set Python alias (Ubuntu 24.04 ships Python 3.12)
RUN ln -sf /usr/bin/python3 /usr/bin/python

# Allow pip to install packages system-wide in the container (PEP 668)
ENV PIP_BREAK_SYSTEM_PACKAGES=1

# Set working directory
WORKDIR /app

# Install PyTorch and torchcodec (datasets decodes audio with torchcodec, which needs the
# matching torch and the ffmpeg libraries installed above).
# NOTE: the ABR models are torch.export graphs (.pt2). A graph loads in the torch that
# exported it or a newer one, never an older one, so this pin tracks the torch the models
# were exported with (see the model cards).
RUN pip install --no-cache-dir \
    torch==2.14.0 \
    torchcodec==0.16.0 \
    --index-url https://download.pytorch.org/whl/cu130

# Install common requirements
RUN pip install --no-cache-dir \
    transformers \
    evaluate \
    datasets \
    jiwer \
    num2words \
    "kaldialign>=0.12.0"

# Install ABR-specific dependencies
RUN pip install --no-cache-dir \
    sentencepiece

# Copy the full repository
COPY . /app

# Default entrypoint
ENTRYPOINT ["bash"]

EXPOSE 7860
CMD ["-c", "python3 -m http.server 7860"]
