Files
rose-ash/deploy.sh
giles c72a5af04d WIP: pre-existing changes from WASM browser work + test infrastructure
Accumulated changes from WASM browser development sessions:
- sx_runtime.ml: signal subscription + notify, env unwrap tolerance
- sx_browser.bc.js: rebuilt js_of_ocaml browser kernel
- sx_browser.bc.wasm.js + assets: WASM browser kernel build
- sx-platform.js browser tests (test_js, test_platform, test_wasm)
- Playwright sx-inspect.js: interactive page inspector tool
- harness-web.sx: DOM assertion updates
- deploy.sh, Dockerfile, dune-project: build config updates
- test-stepper.sx: stepper unit tests
- reader-macro-demo plan update

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 16:40:38 +00:00

76 lines
1.9 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
REGISTRY="registry.rose-ash.com:5000"
APPS="blog market cart events federation account relations likes orders test sx_docs"
usage() {
echo "Usage: deploy.sh [app ...]"
echo " deploy.sh blog # rebuild + restart blog only"
echo " deploy.sh blog market # rebuild + restart blog and market"
echo " deploy.sh --all # rebuild + restart all apps"
echo " deploy.sh # auto-detect changed apps via git"
exit 1
}
cd "$(dirname "$0")"
_app_dir() {
# Map compose service name to source directory when they differ
case "$1" in
sx_docs) echo "sx" ;;
*) echo "$1" ;;
esac
}
# Determine which apps to build
if [ $# -eq 0 ]; then
# Auto-detect: uncommitted changes + last commit
CHANGED=$(git diff --name-only HEAD 2>/dev/null; git diff --name-only HEAD~1 HEAD 2>/dev/null || true)
BUILD=()
if echo "$CHANGED" | grep -q "^shared/"; then
BUILD=($APPS)
else
for app in $APPS; do
dir=$(_app_dir "$app")
if echo "$CHANGED" | grep -q "^$dir/"; then
BUILD+=("$app")
fi
done
fi
if [ ${#BUILD[@]} -eq 0 ]; then
echo "No app changes detected. Pass app names or --all."
exit 0
fi
elif [ "$1" = "--all" ]; then
BUILD=($APPS)
elif [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
usage
else
BUILD=("$@")
fi
echo "Building: ${BUILD[*]}"
echo ""
# --- Run unit tests before deploying (skip Playwright — needs running server) ---
if ! QUICK=true ./run-tests.sh; then
exit 1
fi
for app in "${BUILD[@]}"; do
dir=$(_app_dir "$app")
echo "=== $app ==="
docker build -f "$dir/Dockerfile" -t "$REGISTRY/$app:latest" .
docker push "$REGISTRY/$app:latest"
case "$app" in
sx_docs) svc="sx-web_sx_docs" ;;
*) svc="coop_$app" ;;
esac
docker service update --force "$svc" 2>/dev/null \
|| echo " (service $svc not running — will start on next stack deploy)"
echo ""
done
echo "Done."