Spaces:
Running on CPU Upgrade

barha's picture
Deploy bf9e125: the relay to the playground endpoint
8e665ab verified
Raw History Blame Contribute Delete
1.77 kB
# Granite Switch Playground: the sentences app voiced by ProsodyLM, served from one Inference
# Endpoint with one H200.
#
# The demo (Granite Switch, ProsodyLM and the app) runs on the endpoint as on a Blue Vela node
# (scripts/deploy_hf_endpoints.py, deploy/hf/endpoints/app.sh). This Space only relays the page
# and its WebSocket to it (relay.py), with the Space secret LLM_API_KEY: an ibm-granite token
# that can call Inference Endpoints.
FROM python:3.12-slim
COPY --from=ghcr.io/astral-sh/uv:0.12.5 /uv /uvx /usr/local/bin/
# git, wget and curl are not for the relay. With Dev Mode on, HF appends openvscode-server
# layers that run `git config --global` and `wget`; python:3.12-slim has neither, and an
# injected layer then exits 127 with a misleading error naming /dev-mode/init-process.
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates git wget curl \
&& rm -rf /var/lib/apt/lists/*
# Spaces run the container as UID 1000, and python:3.12-slim has no passwd entry for it.
RUN useradd -m -u 1000 user
ENV HOME=/home/user \
PATH=/opt/venv/bin:$PATH \
PYTHONUNBUFFERED=1 \
PORT=7860 \
UV_NO_CACHE=1 \
UV_COMPILE_BYTECODE=1
# The versions the app itself pins (deploy/vela/web/requirements.txt).
RUN uv venv --python /usr/local/bin/python3.12 /opt/venv \
&& uv pip install --python /opt/venv/bin/python \
fastapi==0.142.2 starlette==1.7.0 uvicorn==0.54.0 httpx==0.28.1 websockets==17.2
WORKDIR /app
COPY deploy/hf/relay.py ./relay.py
# The endpoint scales to zero after an idle hour; the relay shows a waking page meanwhile.
ENV APP_URL=https://6b06a645938ee8479c23298c.endpoints.huggingface.cloud
RUN chown -R 1000:1000 /home/user /app
USER user
EXPOSE 7860
CMD ["python", "relay.py"]