polygen-demo / Dockerfile
ga11en's picture
Fetch the polygen wheel from the private repo at build time (WHEEL_TOKEN secret); remove it from the public tree
49f2ceb verified
Raw
History Blame Contribute Delete
1.9 kB
# syntax=docker/dockerfile:1
# Docker Space for the polygen tokenization demo (public).
#
# A gradio-SDK Space cannot install the wheel (HF mounts requirements.txt and
# runs pip before copying repo files), and polygen requires Python 3.13. A
# Docker base solves both. The wheel is Nuitka-compiled (a binary .so, no
# readable source), and it is NOT in this public repo: it is fetched at build
# time from the private datas3nt/polygen-wheel repo via the WHEEL_TOKEN build
# secret (a fine-grained read-only HF token scoped to that repo), so the
# compiled artifact is not publicly downloadable. mlx[cpu] resolves at
# install on Linux x86.
FROM python:3.13-slim
WORKDIR /app
# git: required by HF Spaces' build wrapper (git config / dev-mode steps),
# which the slim base lacks. curl fetches the private wheel below.
RUN apt-get update && apt-get install -y --no-install-recommends git curl \
&& rm -rf /var/lib/apt/lists/*
# Deps first so this layer caches across code edits.
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
# The polygen wheel, fetched from the private repo. The downloaded file MUST
# keep the full wheel filename: pip rejects a wheel whose filename is not a
# valid name-version-tags string.
RUN --mount=type=secret,id=WHEEL_TOKEN \
WHL=polygen-0.1.0b1-cp313-cp313-linux_x86_64.whl && \
TOKEN="$(cat /run/secrets/WHEEL_TOKEN)" && \
curl -fsSL -H "Authorization: Bearer ${TOKEN}" \
"https://huggingface.co/datas3nt/polygen-wheel/resolve/main/${WHL}" -o "/tmp/${WHL}" && \
pip install --no-cache-dir "/tmp/${WHL}" && rm -f "/tmp/${WHL}"
# App code.
COPY . .
# gradio binds all interfaces on the HF app port; analytics off.
ENV GRADIO_SERVER_NAME=0.0.0.0 \
GRADIO_SERVER_PORT=7860 \
GRADIO_ANALYTICS_ENABLED=False \
GRADIO_SSR_MODE=False \
GRADIO_TEMP_DIR=/tmp/gradio
EXPOSE 7860
CMD ["python", "app.py"]