# syntax=docker/dockerfile:1
FROM python:3.12-trixie

ARG APPLIO_COMMIT=45f2dcbb9c6dfaa188c5428f4d56297e1e30a63c
ENV PATH=/app/.venv/bin:$PATH \
    HF_HOME=/models/huggingface \
    PIP_DISABLE_PIP_VERSION_CHECK=1

RUN apt-get update && apt-get install -y --no-install-recommends \
      ca-certificates curl ffmpeg git libportaudio2 \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app
RUN git clone https://github.com/IAHispano/Applio.git . \
    && git checkout "$APPLIO_COMMIT" \
    && python3 -m venv /app/.venv \
    && pip install --no-cache-dir --upgrade pip \
    && pip install --no-cache-dir python-ffmpeg \
    && pip install --no-cache-dir torch==2.7.1 torchvision==0.22.1 torchaudio==2.7.1 \
       --index-url https://download.pytorch.org/whl/cu128 \
    && sed -i '/^torch==/d;/^torchvision==/d;/^torchaudio==/d' requirements.txt \
    && pip install --no-cache-dir -r requirements.txt \
    && pip install --no-cache-dir "websockets>=13.0"

EXPOSE 6969
CMD ["python3", "app.py", "--server-name", "0.0.0.0", "--port", "6969"]
