# Dedicated sheet-music transcription worker (Kyutai MuScriptor).
# Heavy: installs torch + muScriptor + MuseScore (for engraving MusicXML/PDF).
# Needs HUGGINGFACE_TOKEN at runtime to download gated CC BY-NC weights.
FROM python:3.11-slim

ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1

WORKDIR /app

# torch/transformers need libgomp; MuseScore does the engraving for --format sheets
RUN apt-get update \
    && apt-get install -y --no-install-recommends ca-certificates libgomp1 musescore3 \
    && ln -sf /usr/bin/musescore3 /usr/local/bin/musescore \
    && rm -rf /var/lib/apt/lists/*

COPY portal/requirements.txt /tmp/req.txt
RUN pip install --no-cache-dir -r /tmp/req.txt

RUN pip install --no-cache-dir --upgrade pip "setuptools<81" wheel \
    && pip install --no-cache-dir muScriptor

COPY . /app/

CMD ["celery", "-A", "portal.tasks.celery_app", "worker", "-Q", "transcription-mus", "--concurrency=1", "--loglevel=info"]