yue2-studio / Dockerfile
RalphThings's picture
Upload folder using huggingface_hub
6a6bd27 verified
Raw History Blame Contribute Delete
3.9 kB
# YuE2 Studio as a single Hugging Face Space.
#
# One container, two processes: ComfyUI holds the model on an internal port,
# and the studio UI is what the Space actually exposes on 7860. Nothing but the
# UI is reachable from outside, so the ComfyUI API is never public.
#
# Spaces give no GPU at build time, so nothing here touches CUDA.
FROM nvidia/cuda:12.4.1-cudnn-runtime-ubuntu22.04
ARG COMFY_REF=master
# Bumped by hand to make a rebuild obvious in the running container's log.
ARG BUILD_STAMP=2026-09-18-score-playback
ENV DEBIAN_FRONTEND=noninteractive \
PIP_NO_CACHE_DIR=1 \
PYTHONUNBUFFERED=1 \
NODE_MAJOR=20 \
CC=gcc \
CXX=g++
RUN apt-get update && apt-get install -y --no-install-recommends \
python3.10 python3.10-venv python3.10-dev \
build-essential \
git git-lfs ffmpeg libsndfile1 curl ca-certificates gnupg \
&& mkdir -p /etc/apt/keyrings \
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key \
| gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" \
> /etc/apt/sources.list.d/nodesource.list \
&& apt-get update && apt-get install -y --no-install-recommends nodejs \
&& rm -rf /var/lib/apt/lists/*
# Spaces run the container as uid 1000.
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
WORKDIR $HOME
# --- ComfyUI, the engine -----------------------------------------------------
#
# An explicit venv rather than whatever `python3` the base image happens to
# resolve to. Ubuntu 22.04 publishes python3.11 as 3.11.0~rc1, a release
# candidate predating sys.get_int_max_str_digits, which torch._dynamo needs.
# Choosing the interpreter here means the base image cannot decide it for us.
ENV VIRTUAL_ENV=$HOME/venv
RUN python3.10 -m venv $VIRTUAL_ENV
ENV PATH=$VIRTUAL_ENV/bin:$PATH
RUN git clone --depth 1 --branch $COMFY_REF https://github.com/comfyanonymous/ComfyUI.git $HOME/ComfyUI
RUN python -m pip install --upgrade pip \
&& python -m pip install "torch>=2.7,<3" torchvision torchaudio \
&& python -m pip install -r $HOME/ComfyUI/requirements.txt \
&& python -m pip install "huggingface_hub>=0.36.0"
# Lyric transcription. transformers already came in with ComfyUI, so Whisper
# costs nothing but its weights; demucs is the only real addition. Its checkpoint
# comes from Meta's CDN rather than the Hub, so preload_from_hub cannot cache it
# and it is fetched here instead of on the first upload.
RUN python -m pip install "demucs>=4.0.1" \
&& python -c "from demucs.pretrained import get_model; get_model('htdemucs')"
# Both engine failures so far were import-time and only surfaced at runtime.
# Checking here fails the image instead of shipping a dead backend.
COPY --chown=user scripts/verify-engine.py /tmp/verify-engine.py
RUN python /tmp/verify-engine.py
# --- the studio, the face ----------------------------------------------------
WORKDIR $HOME/app
COPY --chown=user package.json package-lock.json ./
RUN npm ci
COPY --chown=user . .
# verify fails the image if the stylesheet did not compile, because an unstyled
# page otherwise ships looking like a healthy deploy.
RUN npm run build && npm run verify
# Assemble what the standalone server expects beside it. Hashed assets live
# here rather than being resolved out of the build tree, so the served HTML and
# the files on disk cannot disagree.
RUN cp -r .next/static .next/standalone/.next/static \
&& if [ -d public ]; then cp -r public .next/standalone/public; fi \
&& ls -la .next/standalone/.next/static/chunks/*.css
ENV COMFY_URL=http://127.0.0.1:8188 \
COMFY_MOCK=0 \
PORT=7860 \
HOSTNAME=0.0.0.0 \
BUILD_STAMP=$BUILD_STAMP
EXPOSE 7860
CMD ["bash", "/home/user/app/scripts/space-start.sh"]