FROM python:3.11-slim RUN apt-get update && apt-get install -y --no-install-recommends \ ffmpeg libsndfile1 build-essential git \ && rm -rf /var/lib/apt/lists/* WORKDIR /app # Install CUDA-enabled torch FIRST so pip satisfies torch>=2.5.0 # from the CUDA index rather than pulling the CPU-only wheel from PyPI. RUN pip install --no-cache-dir \ "torch>=2.5.0,<3.0" "torchaudio>=2.5.0,<3.0" \ --index-url https://download.pytorch.org/whl/cu121 COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt COPY . . RUN mkdir -p /app/temp /app/model_cache ENV MPLBACKEND=Agg ENV PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True ENV HF_HOME=/app/model_cache ENV GRADIO_ANALYTICS_ENABLED=false ENV PYTHONPATH=/app ENV CONFIG_PATH=/app/config/settings.yaml # HF Spaces requires the process to run as UID 1000 RUN adduser --disabled-password --gecos '' --uid 1000 hfuser \ && chown -R hfuser:hfuser /app USER 1000 EXPOSE 7860 CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]