FROM mike-ai/bs-roformer-separator:0.47.0

ARG AMPHION_COMMIT=26f6883110181f1dbfe95c70a7c7dbaf4de5f42a

USER root
RUN apt-get update \
    && apt-get install -y --no-install-recommends git espeak-ng \
    && rm -rf /var/lib/apt/lists/*

RUN git clone https://github.com/open-mmlab/Amphion.git /opt/amphion \
    && cd /opt/amphion \
    && git checkout "${AMPHION_COMMIT}" \
    && rm -rf .git

# Vevo2 is tested on Athena with the CUDA/PyTorch stack inherited from the
# existing audio worker. Do not install Amphion's historical torch 2.0/cu118
# pins: Blackwell requires the newer cu128 runtime already present here.
RUN python -m pip install --no-cache-dir \
      accelerate==1.10.1 \
      diffusers==0.35.1 \
      einops==0.8.1 \
      easydict==1.13 \
      g2p_en==2.1.0 \
      humanfriendly==10.0 \
      huggingface-hub==0.34.4 \
      hydra-core==1.3.2 \
      inflect==7.5.0 \
      ipython==9.5.0 \
      json5==0.12.1 \
      librosa==0.11.0 \
      loguru==0.7.3 \
      matplotlib==3.10.6 \
      munch==4.0.0 \
      omegaconf==2.3.0 \
      openai-whisper==20250625 \
      phonemizer==3.3.0 \
      python-multipart==0.0.20 \
      praat-parselmouth==0.4.6 \
      pypinyin==0.55.0 \
      pyworld==0.3.5 \
      ruamel.yaml==0.18.15 \
      safetensors==0.6.2 \
      tabulate==0.9.0 \
      tgt==1.5 \
      torchcrepe==0.0.24 \
      transformers==4.56.1 \
      typeguard==4.4.4 \
      unidecode==1.4.0 \
      vector-quantize-pytorch==1.12.5 \
      vocos==0.1.0

WORKDIR /opt/amphion
ENV PYTHONPATH=/opt/amphion \
    HF_HOME=/models/huggingface \
    PYTHONUNBUFFERED=1

COPY run_fm_test.py /usr/local/bin/run_fm_test.py
COPY app.py /app/app.py
COPY index.html /app/index.html

EXPOSE 8008
HEALTHCHECK --interval=5s --timeout=3s --start-period=90s --retries=3 \
  CMD curl -fsS http://127.0.0.1:8008/health || exit 1
ENTRYPOINT ["python", "/app/app.py"]
