FROM python:3.11-slim # System deps for torchaudio + soundfile RUN apt-get update && apt-get install -y --no-install-recommends \ ffmpeg \ libsndfile1 \ git \ && rm -rf /var/lib/apt/lists/* WORKDIR /app # Install Python deps first (layer cache) COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy app code COPY . . # HuggingFace Spaces runs as a non-root user — ensure writable dirs RUN mkdir -p /app/dataset/audio /app/static && \ chmod -R 777 /app/dataset /app/static # HuggingFace Spaces always expects port 7860 EXPOSE 7860 CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]