cyberhybridhub/scripts/deploy-dev.sh
2026-06-04 20:51:03 +00:00

45 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# Fast deploy: build release web (no pub get) and restart production services.
# Use after git pull when dependencies are already installed.
#
# ./scripts/deploy-dev.sh
#
# Full deploy with package refresh: ./scripts/deploy-production.sh
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT"
if [ -f "$ROOT/scripts/flutter-env.sh" ]; then
# shellcheck source=/dev/null
source "$ROOT/scripts/flutter-env.sh"
fi
echo "==> Flutter web (release, no pub get)"
SKIP_PUB_GET=1 "$ROOT/scripts/build-production-web.sh"
if grep -qE 'http://cyberhybridhub\.com:3000|https://cyberhybridhub\.com:3000' \
"$ROOT/build/web/main.dart.js" 2>/dev/null; then
echo "ERROR: build/web still bakes :3000 API URL — fix hosting/hosting.env and rebuild." >&2
exit 1
fi
echo "==> Restart services"
if ! command -v systemctl >/dev/null 2>&1; then
echo "systemctl not found; skip service restart." >&2
exit 0
fi
for unit in cyberhybridhub-api cyberhybridhub-web; do
if ! systemctl list-unit-files --type=service "$unit.service" >/dev/null 2>&1; then
echo "Warning: $unit.service not installed (run ./hosting/install-systemd.sh once)" >&2
exit 1
fi
done
sudo systemctl restart cyberhybridhub-api cyberhybridhub-web
sudo systemctl --no-pager --full status cyberhybridhub-api cyberhybridhub-web || true
echo ""
echo "Dev deploy done. Hard-refresh the browser if the UI looks stale."