| FROM python:3.12-slim | |
| # System deps for audio processing (librosa, soundfile) | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| libsndfile1 \ | |
| ffmpeg \ | |
| && rm -rf /var/lib/apt/lists/* | |
| WORKDIR /app | |
| # Install torch + torchaudio CPU-only (saves ~2.3GB vs full CUDA build) | |
| RUN pip install --no-cache-dir \ | |
| torch torchaudio --index-url https://download.pytorch.org/whl/cpu | |
| # Force cache invalidation | |
| ARG CACHEBUST=6 | |
| # Install remaining dependencies | |
| COPY requirements-deploy.txt . | |
| RUN pip install --no-cache-dir -r requirements-deploy.txt | |
| # Copy source code | |
| COPY src/ src/ | |
| COPY config.yaml . | |
| COPY scripts/cache_models.py scripts/cache_models.py | |
| # Pre-download ML models at build time (avoids cold-start downloads) | |
| ARG HF_TOKEN | |
| ENV HF_TOKEN=${HF_TOKEN} | |
| RUN python scripts/cache_models.py | |
| # Create data directory for SQLite + uploads | |
| RUN mkdir -p data/samples | |
| # HF Spaces port | |
| ENV PORT=7860 | |
| EXPOSE 7860 | |
| CMD ["uvicorn", "src.stage4.main:app", "--host", "0.0.0.0", "--port", "7860"] | |