Spaces:
Running
Running
File size: 1,870 Bytes
3c124f3 | 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 | # Puck — Hugging Face Space (Docker SDK).
# Two stages: build the React UI, then run the gr.Server daemon that serves it AND
# proxies "peeks" to the cloud (Modal) vision brain. The macOS-only paths (screen OCR,
# `say` voice, ONNX recognizer) self-disable on Linux; the Space hosts the browser SIM,
# whose vision runs against Modal. Custom UI over gr.Server = the Off-Brand badge.
# ---- stage 1: build the frontend ----
FROM node:24-slim AS web
WORKDIR /web
COPY frontend/package.json frontend/package-lock.json* ./
RUN npm ci || npm install
COPY frontend/ ./
RUN npm run build # → /web/dist
# ---- stage 2: python daemon ----
FROM ghcr.io/astral-sh/uv:python3.14-bookworm-slim
# HF Spaces run as uid 1000 — give it a writable HOME for the peek log + uv cache.
RUN useradd -m -u 1000 user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH \
UV_LINK_MODE=copy \
UV_COMPILE_BYTECODE=1 \
PUCK_HOST=0.0.0.0 \
PORT=7860 \
PUCK_VISION_URL=https://vuluan--puck-brain-serve.modal.run/v1 \
PUCK_VISION_MODEL=Hcompany/Holotron-12B \
PUCK_VISION_TIMEOUT=120
WORKDIR /home/user/app
# deps first (cached across code edits); the server's lockfile drives the resolve
COPY --chown=user:user server/pyproject.toml server/uv.lock ./server/
RUN cd server && uv sync --no-dev
# app code + the assets app.py reads at import (schema/) + the built UI
COPY --chown=user:user server/ ./server/
COPY --chown=user:user schema/ ./schema/
COPY --chown=user:user --from=web /web/dist ./frontend/dist
RUN mkdir -p server/data && chown -R user:user /home/user/app
USER user
EXPOSE 7860
WORKDIR /home/user/app/server
# Run the venv's interpreter directly — no `uv` at runtime (it would hit a root-owned
# build-time cache, and we don't want a re-resolve on boot). The env is already synced.
CMD ["/home/user/app/server/.venv/bin/python", "app.py"]
|