#!/usr/bin/env bash # Deploy dist/ to play-pce.supertux.com: # this machine's docker stack, an nginx:alpine container serving /docker/appdata/play-pce read-only behind # Traefik (deploy/play-pce.yml, the stack's emu.yml with the name changed). # nginx serves new files without a restart. # Usage: scripts/deploy.sh (builds dist/ first) # scripts/deploy.sh --no-build set -euo pipefail ROOT=$(cd "$(dirname "$0")/.." && pwd) cd "$ROOT" STACK=${STACK:-/docker/compose} SITE=${SITE:-/docker/appdata/play-pce} URL=${URL:-https://play-pce.supertux.com} [ "${1:-}" = "--no-build" ] || scripts/build-dist.sh [ -f dist/version.json ] || { echo "no dist/version.json; build first"; exit 1; } mkdir -p "$SITE" rsync -a --delete dist/ "$SITE/" # A changed service file (its Traefik labels, say) needs the container recreated; # compose's up -d does that, and starts it if it is not running. changed=false if ! cmp -s deploy/play-pce.yml "$STACK/apps/play-pce.yml" 2>/dev/null; then cp deploy/play-pce.yml "$STACK/apps/play-pce.yml" echo "installed $STACK/apps/play-pce.yml" changed=true fi if $changed || ! docker ps --format '{{.Names}}' | grep -qx play-pce; then (cd "$STACK" && docker compose --env-file .env -f apps/play-pce.yml up -d) fi echo "deployed $(cat dist/version.json)" sleep 2 curl -sS -o /dev/null -w "$URL/ -> %{http_code} %{content_type}\n" "$URL/" curl -sS -o /dev/null -w "$URL/pkg/play_pce_bg.wasm -> %{http_code} %{content_type}\n" "$URL/pkg/play_pce_bg.wasm" curl -sS "$URL/version.json"