#!/usr/bin/env bash # Deploy dist/ to galaxian.supertux.com: this machine's docker stack, an # nginx:alpine container serving /docker/appdata/galaxian read-only behind # Traefik (deploy/galaxian.yml, a copy of the stack's galaga.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/galaxian} URL=${URL:-https://galaxian.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/" if ! cmp -s deploy/galaxian.yml "$STACK/apps/galaxian.yml" 2>/dev/null; then cp deploy/galaxian.yml "$STACK/apps/galaxian.yml" echo "installed $STACK/apps/galaxian.yml" fi if ! docker ps --format '{{.Names}}' | grep -qx galaxian; then (cd "$STACK" && docker compose --env-file .env -f apps/galaxian.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/z80_wasm_bg.wasm -> %{http_code} %{content_type}\n" "$URL/pkg/z80_wasm_bg.wasm" curl -sS "$URL/version.json"