File size: 1,639 Bytes
c631404
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
48
49
#!/usr/bin/env bash
# Deploy NumberVault to a Hugging Face Docker-less Gradio Space on CPU.
#
# Required environment:
#   HF_TOKEN          Hugging Face access token with write access
#   ADMIN_PASSWORD    Dashboard password (>= 10 chars)
# Optional:
#   SPACE_ID          default: nezuhub/number-vault
#   BUCKET_ID         default: nezuhub/numbervault-storage
#   TELEGRAM_BOT_TOKEN, ADMIN_TELEGRAM_IDS, ADMIN_CHAT_ID, PAYMENT_UPI
set -euo pipefail

SPACE_ID="${SPACE_ID:-nezuhub/number-vault}"
BUCKET_ID="${BUCKET_ID:-nezuhub/numbervault-storage}"
ROOT="$(cd "$(dirname "$0")/.." && pwd)"

: "${HF_TOKEN:?Set HF_TOKEN}"
: "${ADMIN_PASSWORD:?Set ADMIN_PASSWORD (>=10 chars)}"

hf repos create "$SPACE_ID" --type space --sdk gradio --flavor cpu-basic \
  --exist-ok --private

hf spaces volumes set "$SPACE_ID" -v "hf://buckets/${BUCKET_ID}:/data"

SECRETS=("ADMIN_PASSWORD=${ADMIN_PASSWORD}")
for name in TELEGRAM_BOT_TOKEN ADMIN_TELEGRAM_IDS ADMIN_CHAT_ID PAYMENT_UPI; do
  if [[ -n "${!name:-}" ]]; then
    SECRETS+=("${name}=${!name}")
  fi
done
hf spaces secrets set "$SPACE_ID" "${SECRETS[@]}"

hf spaces variables set "$SPACE_ID" \
  ENV=production \
  DATA_DIR=/tmp/numbervault \
  BUCKET_MOUNT=/data \
  BUCKET_ENABLED=auto \
  CURRENCY=INR \
  TIMEZONE=Asia/Kolkata

hf upload "$SPACE_ID" "$ROOT" . \
  --exclude ".venv/**" --exclude ".git/**" --exclude ".env" \
  --exclude "**/__pycache__/**" --exclude ".pytest_cache/**" \
  --exclude "*.db" --exclude "*.db-wal" --exclude "*.db-shm"

hf spaces wait "$SPACE_ID"
echo "Space: https://huggingface.co/spaces/${SPACE_ID}"
echo "Health: https://${SPACE_ID/\//-}.hf.space/health"