CoolFace
Apppublic

SoftwareResearch/g2dm-research

sourceHugging Faceupdated 4mo agoView on Hugging Face
0likes
deploy_hf.sh83 linesDownload Raw Back to root
1#!/usr/bin/env bash2# One-command deploy to a Hugging Face Space (Docker) for always-on free hosting.3#4# Prereqs (one-time, ~2 min — these are yours; I don't handle accounts/keys):5#   1) Free account:   https://huggingface.co/join6#   2) Blank Space:    https://huggingface.co/new-space7#        - Name it (e.g. g2dm-research), SDK = Docker (blank), visibility your choice8#   3) Write token:    https://huggingface.co/settings/tokens  (role: "Write")9#10# Usage:11#   ./deploy_hf.sh <hf-username> <space-name>12# At the git prompt: username = your HF username, password = your WRITE TOKEN.13#14# After it pushes, set two SECRETS in the Space (Settings -> Variables and secrets):15#   ANTHROPIC_API_KEY = your Claude key16#   APP_PASSWORD      = a shared team password   (login username is "team")17#18# Set DRY_RUN=1 to build the bundle and stop before pushing (for inspection).19set -e20cd "$(dirname "$0")"21 22HF_USER="$1"; SPACE="$2"23if [ -z "$HF_USER" ] || [ -z "$SPACE" ]; then24  echo "Usage: ./deploy_hf.sh <hf-username> <space-name>"; exit 125fi26 27command -v git >/dev/null || { echo "git is required (install Xcode Command Line Tools: xcode-select --install)"; exit 1; }28 29STAGE="$(mktemp -d)"30echo "Staging deploy bundle in $STAGE …"31# Ship only what the Space needs — never the venv, secrets, or local binaries.32for f in app.py research_engine.py considerations.py html_extract.py prompts.py \33         requirements.txt Dockerfile gunicorn.conf.py; do34  cp "$f" "$STAGE/"35done36cp -R static "$STAGE/static"37 38# HF Spaces require this YAML metadata block at the top of README.md.39cat > "$STAGE/README.md" <<'EOF'40---41title: G2DM Product Fitment Research42emoji: 🔎43colorFrom: red44colorTo: gray45sdk: docker46app_port: 786047pinned: false48---49 50# G2DM Product Fitment Research51 52Internal research tool. Access is password-gated (set APP_PASSWORD as a Space secret).53EOF54 55( cd "$STAGE"56  git init -q57  git add -A58  git -c user.email=deploy@local -c user.name=deploy commit -qm "Deploy G2DM research tool"59  git branch -M main60)61 62if [ "$DRY_RUN" = "1" ]; then63  echo "DRY_RUN: bundle ready at $STAGE (not pushed). Contents:"64  ls -1 "$STAGE"65  exit 066fi67 68( cd "$STAGE"69  git remote add origin "https://huggingface.co/spaces/${HF_USER}/${SPACE}"70  echo ""71  echo "Pushing to https://huggingface.co/spaces/${HF_USER}/${SPACE}"72  echo "  → username = your HF username, password = your HF WRITE TOKEN"73  echo ""74  git push -u origin main --force75)76 77echo ""78echo "✓ Pushed. The Space will build (Docker) in ~2-4 min."79echo "  Now set secrets at: https://huggingface.co/spaces/${HF_USER}/${SPACE}/settings"80echo "    ANTHROPIC_API_KEY = your Claude key"81echo "    APP_PASSWORD      = a shared team password (login user is 'team')"82echo "  Then share: https://${HF_USER}-${SPACE}.hf.space"83