setup.sh
65 lignes · 2072 octets
#!/usr/bin/env bash # Start the three-instance Rustwarden fediverse testbed. # # Steps: # 1. docker compose up -d --wait -> postgres + apps healthy # 2. wait for seed-* jobs to exit 0 -> Happy Days users loaded # 3. configure-trust.sh -> cross-instance allowlist # 4. smoke-check /health on the 3 apps -> visible from the host set -euo pipefail cd "$(dirname "$0")/.." echo "==> docker compose up (build + start, wait for health)" # `--wait` waits for: services with healthcheck to become healthy, AND # one-shot services (restart:no, no healthcheck) to exit 0. So when this # returns, migrate-* and seed-* are guaranteed to have completed # successfully — no separate wait loop needed. docker compose up -d --wait --wait-timeout 300 echo "==> Verifying one-shot jobs exited 0" for job in migrate-alpha migrate-beta migrate-gamma \ migrate-fediverse-alpha migrate-fediverse-beta migrate-fediverse-gamma \ migrate-fediverse-guard-alpha migrate-fediverse-guard-beta migrate-fediverse-guard-gamma \ seed-alpha seed-beta seed-gamma; do code=$(docker inspect -f '{{.State.ExitCode}}' "rustwarden-fediverse-testbed-${job}-1") if [ "$code" != "0" ]; then echo " $job FAILED (exit $code)" docker compose logs "$job" | tail -40 exit 1 fi echo " $job ok" done echo "==> Configuring cross-instance trust" ./scripts/configure-trust.sh echo "==> Host-side smoke checks" for port in 3001 3002 3003; do echo -n " http://localhost:$port/health ... " if curl -fsS "http://localhost:$port/health" >/dev/null; then echo "ok" else echo "FAILED" exit 1 fi done cat <<'EOF' ==> Testbed ready. Instances: alpha.local -> http://localhost:3001 (DB rustwarden_alpha) beta.local -> http://localhost:3002 (DB rustwarden_beta) gamma.local -> http://localhost:3003 (DB rustwarden_gamma) Seeded admin (per instance): email joanie@rustwarden.local password happydays123 To stop and purge everything: ./scripts/teardown.sh EOF
GitRust