FROM python:3.11-slim RUN apt-get update && apt-get install -y --no-install-recommends ffmpeg libsndfile1 && rm -rf /var/lib/apt/lists/* WORKDIR /app # CPU-only torch first (much smaller than the default CUDA wheels), then the rest. RUN pip install --no-cache-dir torch==2.4.1 torchaudio==2.4.1 --index-url https://download.pytorch.org/whl/cpu COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Bake the htdemucs weights (~172 MB) into the image so cold starts don't re-download. RUN python -c "from demucs.pretrained import get_model; get_model('htdemucs')" COPY app.py . EXPOSE 7860 CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]