#!/usr/bin/env bash # Build locally, push the static site and the duel server to the droplet, # and restart the server. Usage: deploy/deploy.sh set -euo pipefail HOST="${1:?usage: deploy.sh }" npm run check npm run check:server npm test npm run build # Old hashed chunks stay a week: a page loaded before this deploy can still # fetch the module it was built against instead of failing mid-duel. rsync -az --delete --filter='P _app/immutable/*' \ build/ "root@$HOST:/opt/waving-hands/build/" # The server runs from source with tsx and carries its own small manifest; # it needs only its code and the engine. Ledgers live outside this tree. rsync -az --delete --exclude='/server/node_modules' \ --include='/server/***' --include='/src/' --include='/src/lib/' --include='/src/lib/game/***' \ --include='/deploy/' --include='/deploy/waving-hands.service' --include='/deploy/visitors.sh' \ --exclude='*' \ ./ "root@$HOST:/opt/waving-hands/app/" ssh "root@$HOST" ' find /opt/waving-hands/build/_app/immutable -type f -mtime +7 -delete chown -R root:caddy /opt/waving-hands/build chmod -R g+rX /opt/waving-hands/build cd /opt/waving-hands/app/server && npm install --no-audit --no-fund chown -R waving-hands:waving-hands /opt/waving-hands/app cp /opt/waving-hands/app/deploy/waving-hands.service /etc/systemd/system/waving-hands.service install -m 755 /opt/waving-hands/app/deploy/visitors.sh /usr/local/bin/waving-hands-visitors.sh systemctl daemon-reload systemctl enable --now waving-hands systemctl restart waving-hands systemctl reload caddy sleep 1 systemctl --no-pager -l status waving-hands | head -3 ' echo "deployed."