vtm / Dockerfile
fomext's picture
Upload 4 files
24e6a09 verified
Raw
History Blame Contribute Delete
1.67 kB
# ─────────────────────────────────────────────────────────────────────────────
# 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"]