#!/usr/bin/env bash # Builds and starts the static site under a throwaway project name, checks it, # then removes it. # deploy/check.sh from the repository root or deploy/ # Exits non-zero if any check fails. Needs Docker with Compose v2. set -euo pipefail cd "$(dirname "$0")" project="deadhead-check" env_file=".check.env" port="${CHECK_PORT:-8088}" site="http://localhost:$port" cat > "$env_file" </dev/null 2>&1 || true rm -f "$env_file" } trap cleanup EXIT echo "Building and starting the site…" compose up -d --build --wait --wait-timeout 180 fail=0 expect() { local name="$1" got="$2" pattern="$3" if [[ "$got" == $pattern ]]; then echo "ok $name"; else echo "FAIL $name: $got"; fail=1; fi } header() { curl -sI "$site$1" | tr -d '\r' | grep -i "^$2:" || true; } expect "app shell" "$(curl -s "$site/")" '*Deadhead: Space Freight Tycoon*' expect "client route falls back to the app" "$(curl -s "$site/fleet")" '*
*' expect "service worker is never cached" "$(header /sw.js cache-control)" '*no-cache*' expect "manifest is never cached" "$(header /manifest.webmanifest cache-control)" '*no-cache*' bundle="$(curl -s "$site/" | grep -o '/assets/index-[A-Za-z0-9_-]*\.js' | head -1)" expect "hashed bundle is cached for a year" "$(header "$bundle" cache-control)" '*immutable*' expect "bundle is compressed" "$(curl -sI -H 'Accept-Encoding: gzip' "$site$bundle" | tr -d '\r' | grep -i '^content-encoding:' || true)" '*gzip*' exit "$fail"