summaryrefslogtreecommitdiff
path: root/deploy/deploy.sh
diff options
context:
space:
mode:
authorskylar <me@casper>2026-11-01 05:43:24 -0800
committerskylar <me@casper>2026-11-01 05:43:24 -0800
commite69ad01e700e80fa959dfee08cd556ca0d777ffd (patch)
tree645fc9db2142e87a5ef302733a77ba2fec848d88 /deploy/deploy.sh
Yesod: self-hosted WebXR rooms
Start a room in a world and hang out in VR from the headset's browser: A-Frame + Networked-A-Frame over EasyRTC, with a coturn relay that can hide everyone's IP address. Ships with the Campfire, Temple, Cabin, Balcony and Test room worlds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'deploy/deploy.sh')
-rwxr-xr-xdeploy/deploy.sh48
1 files changed, 48 insertions, 0 deletions
diff --git a/deploy/deploy.sh b/deploy/deploy.sh
new file mode 100755
index 0000000..03ece4a
--- /dev/null
+++ b/deploy/deploy.sh
@@ -0,0 +1,48 @@
+#!/usr/bin/env bash
+# Push the app to a server, install its dependencies there, swap it in, and
+# restart. First-time setup is described in README.md; this is for updates.
+#
+# deploy/deploy.sh [ssh-target]
+#
+# Settings come from the environment or from deploy/deploy.env (not tracked;
+# copy deploy/deploy.env.example):
+# DEPLOY_TARGET ssh target, e.g. root@example.org (or the first argument)
+# APP_DIR where the app lives (default /opt/yesod)
+# SERVICE its systemd unit (default yesod)
+# PORT its port, for the health check (default 8095)
+# NPM the npm command on the server (default npm)
+set -euo pipefail
+
+cd "$(dirname "$0")/.."
+if [ -f deploy/deploy.env ]; then
+ # shellcheck source=/dev/null
+ . deploy/deploy.env
+fi
+
+TARGET="${1:-${DEPLOY_TARGET:-}}"
+APP_DIR="${APP_DIR:-/opt/yesod}"
+SERVICE="${SERVICE:-yesod}"
+PORT="${PORT:-8095}"
+NPM="${NPM:-npm}"
+
+if [ -z "$TARGET" ]; then
+ echo "Set DEPLOY_TARGET in deploy/deploy.env, or pass an ssh target: deploy/deploy.sh root@example.org" >&2
+ exit 1
+fi
+
+tar --exclude=node_modules --exclude=.git --exclude=deno.lock \
+ --exclude='.passphrase*' --exclude='*.local.md' --exclude=deploy --exclude=tools -czf - . \
+ | ssh "$TARGET" "set -e
+ rm -rf $APP_DIR.new
+ mkdir -p $APP_DIR.new
+ tar -C $APP_DIR.new --no-same-owner -xzf -
+ chmod -R u=rwX,go=rX $APP_DIR.new
+ cd $APP_DIR.new
+ $NPM ci --omit=dev --ignore-scripts --no-audit --no-fund --loglevel=error
+ rm -rf $APP_DIR.old
+ if [ -d $APP_DIR ]; then mv $APP_DIR $APP_DIR.old; fi
+ mv $APP_DIR.new $APP_DIR
+ systemctl restart $SERVICE
+ sleep 1
+ systemctl is-active $SERVICE
+ curl -fsS http://127.0.0.1:$PORT/healthz && echo"