File size: 983 Bytes
9484e6f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env sh
# Push this folder to the Hugging Face Space. The Space rebuilds its image and restarts.
#
#   ./deploy.sh            deploy with the engine commit already written in the Dockerfile
#   ./deploy.sh <commit>   pin the engine to that commit of mertkayacs/postkitty, then deploy
#
# Needs the `hf` CLI, logged in with write access to the Space.
set -eu
cd "$(dirname "$0")"
SPACE="${POSTKITTY_SPACE:-mertkayacs/postkitty-api}"

if [ -n "${1:-}" ]; then
  sed -i "s/^ARG POSTKITTY_REF=.*/ARG POSTKITTY_REF=$1/" Dockerfile
fi
ref=$(sed -n 's/^ARG POSTKITTY_REF=//p' Dockerfile)

hf upload "$SPACE" . . --type space \
  --exclude ".venv/*" --exclude ".engine/*" --exclude ".pytest-tmp/*" --exclude ".pytest_cache/*" \
  --exclude "*__pycache__*" \
  --delete "*" \
  --commit-message "deploy with engine ${ref}"

echo "Pushed. Watch the build:  hf spaces logs $SPACE --build"
echo "Then check:               curl https://$(echo "$SPACE" | tr '/' '-').hf.space/v1/health"