TURNCRAFT/deploy/deploy.sh
jing b9ea2f7258 Deploy scripts + relay edit-cap (ship-check finding)
- deploy/deploy.sh: build --base=/turncraft/ -> stage -> docker cp into
  forum-nginx -> reload -> curl verify; syncs relay code + restarts it.
- deploy/setup-relay.sh: one-time relay container on forum-nginx's docker
  network + the nginx location block for /turncraft/ws.
- relay: MAX_EDITS=400k grief ceiling (unbounded diff map could reach
  ~550MB if a bot painted the whole booth).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-13 23:11:54 +10:00

41 lines
1.8 KiB
Bash
Executable File

#!/usr/bin/env bash
# TURNCRAFT deploy — partly.party/turncraft (games VPS humanjing@100.71.119.27)
# Pattern per deploy-map: build -> rsync to /tmp staging -> docker cp into
# forum-nginx web root -> reload -> curl verify. Run from the repo root.
#
# First-time setup (relay service + nginx routes): deploy/setup-relay.sh
set -euo pipefail
VPS="humanjing@100.71.119.27"
STAGE="/tmp/turncraft-stage"
NGINX_CONTAINER="forum-nginx"
# Web root inside forum-nginx — verify with:
# docker exec forum-nginx sh -c 'grep -R "root " /etc/nginx/conf.d | head'
WEBROOT="${TURNCRAFT_WEBROOT:-/usr/share/nginx/html}"
echo "== build =="
npx vite build --base=/turncraft/
echo "== stage on VPS =="
ssh "$VPS" "rm -rf $STAGE && mkdir -p $STAGE"
rsync -az --delete dist/ "$VPS:$STAGE/turncraft/"
echo "== install into $NGINX_CONTAINER:$WEBROOT/turncraft =="
ssh "$VPS" "docker exec $NGINX_CONTAINER rm -rf $WEBROOT/turncraft \
&& docker cp $STAGE/turncraft $NGINX_CONTAINER:$WEBROOT/turncraft \
&& docker exec $NGINX_CONTAINER nginx -s reload"
echo "== relay code sync (server/) =="
rsync -az --delete --exclude node_modules --exclude 'booth-state.json*' \
server/ "$VPS:/home/humanjing/turncraft-relay/"
ssh "$VPS" "docker restart turncraft-relay >/dev/null 2>&1 || echo 'relay container not running — run deploy/setup-relay.sh'"
echo "== verify =="
curl -fsS -o /dev/null -w "static: %{http_code}\n" "https://partly.party/turncraft/?bust=$(date +%s)"
curl -fsS -o /dev/null -w "ws-route: %{http_code}\n" \
-H 'Connection: Upgrade' -H 'Upgrade: websocket' \
-H 'Sec-WebSocket-Version: 13' -H 'Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==' \
"https://partly.party/turncraft/ws" || true # 101/400 = route alive; 404 = missing nginx block
echo "done. If Cloudflare serves a stale bundle, purge the cache."