# ── Paperclip on Hugging Face Spaces ────────────────────────────────────────── # - Listens on port 7860 (HF Spaces default, set in README.md app_port) # - HF Spaces enforces UID 1000 at runtime # - All state stored at /data/paperclip (HF Storage Bucket mount) # - Uses opencode_local adapter → Z.AI Coding Plan API # · glm-5.2 → primary model (complex tasks) # · glm-4.7 → small/fast model (titles, summaries, compaction) # # Fix: original docker-entrypoint.sh calls `gosu` to drop root→node, which # fails on HF Spaces (already UID 1000, not root). We use our own entrypoint # that starts `node /app/server/dist/index.js` directly. # ────────────────────────────────────────────────────────────────────────────── FROM ghcr.io/paperclipai/paperclip:latest USER root # Pre-create /data/paperclip so it exists even before the storage bucket mounts RUN mkdir -p /data/paperclip && chown -R node:node /data # Copy our custom entrypoint and opencode config COPY entrypoint.sh /app/entrypoint.sh COPY opencode.json /app/opencode.json RUN chmod +x /app/entrypoint.sh && chown node:node /app/entrypoint.sh /app/opencode.json # Drop to node user (UID 1000 in the base image) — matches HF Spaces runtime USER node # ── Runtime config ──────────────────────────────────────────────────────────── # PAPERCLIP_HOME=/data/paperclip → all state on the HF Storage Bucket # PORT=7860 → HF Spaces default port # # Set these in HF Space Secrets (Settings → Variables and Secrets): # ZAI_API_KEY — your Z.AI Coding Plan API key # BETTER_AUTH_SECRET — any long random string # PAPERCLIP_PUBLIC_URL — https://YOUR_USERNAME-YOUR_SPACE_NAME.hf.space # PAPERCLIP_ALLOWED_HOSTNAMES — YOUR_USERNAME-YOUR_SPACE_NAME.hf.space ENV HOST=0.0.0.0 \ PORT=7860 \ SERVE_UI=true \ PAPERCLIP_HOME=/data/paperclip \ PAPERCLIP_DEPLOYMENT_MODE=authenticated \ PAPERCLIP_DEPLOYMENT_EXPOSURE=private \ OPENCODE_ALLOW_ALL_MODELS=true EXPOSE 7860 ENTRYPOINT ["/app/entrypoint.sh"]