# ── NoteGrabber API — Docker image ─────────────────────────────────────────── # Builds a lean production image for studio.cloudfom.org's Note Grabber backend. # # Build: docker build -t notegrabber-api . # Run: docker run -p 8000:8000 notegrabber-api # ───────────────────────────────────────────────────────────────────────────── FROM python:3.11-slim # System dependencies needed by librosa / soundfile (used by basic-pitch) RUN apt-get update && apt-get install -y --no-install-recommends \ libsndfile1 \ ffmpeg \ && rm -rf /var/lib/apt/lists/* WORKDIR /app # Install Python dependencies first (layer-cached unless requirements change) COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy application code COPY main.py . # Pre-download the basic-pitch model weights at build time so cold-starts # don't hit the network at runtime. (The model is ~30 MB.) RUN python -c "from basic_pitch import ICASSP_2022_MODEL_PATH; print('Model path:', ICASSP_2022_MODEL_PATH)" EXPOSE 8000 # Use --workers 2 in production (CPU-bound; more workers = more RAM for models) CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "2"]