File size: 1,668 Bytes
24e6a09 | 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 41 42 43 | # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Voice-to-MIDI Β· Hugging Face Spaces Dockerfile
# Base: official Python slim β keeps image small for faster cold starts
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
FROM python:3.10-slim
# HF Spaces runs as a non-root user; create it early
RUN useradd -m -u 1000 appuser
WORKDIR /app
# System deps: ffmpeg for broad audio codec support, libsndfile for soundfile
RUN apt-get update && apt-get install -y --no-install-recommends \
ffmpeg \
libsndfile1 \
libgomp1 \
git \
&& rm -rf /var/lib/apt/lists/*
# Copy and install Python deps as root (writes to site-packages)
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip \
&& pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY app.py .
# Switch to non-root user (required by HF Spaces)
USER appuser
# HF Spaces expects the service on port 7860
EXPOSE 7860
# Pre-warm the Basic Pitch model on container start so the first request
# doesn't pay the cold-start cost. The one-worker uvicorn picks it up.
ENV PYTHONUNBUFFERED=1
ENV OMP_NUM_THREADS=2
ENV TF_NUM_INTEROP_THREADS=2
ENV TF_NUM_INTRAOP_THREADS=2
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", \
"--workers", "1", "--log-level", "info"]
|