File size: 1,900 Bytes
49f2ceb
cae2a70
 
 
 
 
49f2ceb
 
 
 
 
cae2a70
 
 
 
 
49f2ceb
cae2a70
 
 
49f2ceb
 
cae2a70
 
49f2ceb
 
 
 
 
 
 
 
 
 
cae2a70
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# 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"]