File size: 1,014 Bytes
c857b85 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | 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"]
|