From cc47e17c1c62143a15204751d0537d9bc9fcd238 Mon Sep 17 00:00:00 2001 From: Dorian Date: Thu, 5 Mar 2026 08:12:55 +0000 Subject: [PATCH] feat: add --frontend-only flag, SSH pre-flight check, and section timing to deploy script - --frontend-only skips Rust build and container rebuilds (35s vs 130s) - SSH connectivity check fails fast if server is unreachable - Each section now prints elapsed time Co-Authored-By: Claude Opus 4.6 --- .claude/plans/reflective-meandering-castle.md | 2 +- scripts/deploy-to-target.sh | 55 ++++++++++++++++--- 2 files changed, 47 insertions(+), 10 deletions(-) diff --git a/.claude/plans/reflective-meandering-castle.md b/.claude/plans/reflective-meandering-castle.md index a2b26d37..2e31ef77 100644 --- a/.claude/plans/reflective-meandering-castle.md +++ b/.claude/plans/reflective-meandering-castle.md @@ -89,7 +89,7 @@ After getting Claude Max OAuth working on the live server, hardening the deploy - **Change**: Verify each category (apps, system, network, bitcoin, wallet, media, files, search, ai-local, notes) returns real data. Wire any that send placeholder/empty data to real store data. - **Verify**: Chat mode, ask AI about installed apps, gets real context -### Task 16: Deploy script improvements +### Task 16: Deploy script improvements [DONE] - **Files**: `scripts/deploy-to-target.sh` - **Change**: Add SSH connectivity pre-flight check. Add `--frontend-only` flag for CSS/Vue-only deploys (skip Rust build + container rebuilds). Add timing output per section. - **Verify**: `--frontend-only` works, `--live` still works fully diff --git a/scripts/deploy-to-target.sh b/scripts/deploy-to-target.sh index da4e2bc4..e96298c1 100755 --- a/scripts/deploy-to-target.sh +++ b/scripts/deploy-to-target.sh @@ -3,10 +3,11 @@ # Deploy Archipelago code to the HP ProDesk target # # Usage: -# ./scripts/deploy-to-target.sh # Sync and rebuild -# ./scripts/deploy-to-target.sh --quick # Sync only, no rebuild -# ./scripts/deploy-to-target.sh --live # Deploy to live system (default: 192.168.1.228) -# ./scripts/deploy-to-target.sh --both # Deploy to 228, then copy to 198 +# ./scripts/deploy-to-target.sh # Sync and rebuild +# ./scripts/deploy-to-target.sh --quick # Sync only, no rebuild +# ./scripts/deploy-to-target.sh --live # Deploy to live system (default: 192.168.1.228) +# ./scripts/deploy-to-target.sh --both # Deploy to 228, then copy to 198 +# ./scripts/deploy-to-target.sh --frontend-only # Frontend-only deploy (skip Rust build + container rebuilds) # set -e @@ -39,14 +40,33 @@ echo "" QUICK=false LIVE=false BOTH=false +FRONTEND_ONLY=false for arg in "$@"; do case $arg in --quick) QUICK=true ;; --live) LIVE=true ;; --both) BOTH=true ;; + --frontend-only) FRONTEND_ONLY=true; LIVE=true ;; esac done +# Section timing helper +section_start() { SECTION_START=$(date +%s); } +section_end() { + local elapsed=$(($(date +%s) - SECTION_START)) + echo " (${elapsed}s)" +} + +# SSH connectivity pre-flight check +echo "$(timestamp) Checking SSH connectivity..." +if ! sshpass -p "$ARCHIPELAGO_PASSWORD" ssh $SSH_OPTS -o ConnectTimeout=5 "$TARGET_HOST" "echo ok" >/dev/null 2>&1; then + echo " ERROR: Cannot connect to $TARGET_HOST" + echo " Check that the server is on and reachable." + exit 1 +fi +echo " Connected." +echo "" + # When --both: deploy to 228 first, then copy to 198 if [ "$BOTH" = true ]; then echo "Deploying to both servers (228, then 198)..." @@ -73,6 +93,7 @@ if [ "$BOTH" = true ]; then fi # Sync code +section_start echo "$(timestamp) 📦 Syncing code..." sshpass -p "$ARCHIPELAGO_PASSWORD" rsync -avz --delete \ -e "ssh $SSH_OPTS" \ @@ -83,6 +104,7 @@ sshpass -p "$ARCHIPELAGO_PASSWORD" rsync -avz --delete \ --exclude 'image-recipe/build' \ --exclude 'image-recipe/results' \ "$PROJECT_DIR/" "$TARGET_HOST:$TARGET_DIR/" +section_end if [ "$QUICK" = true ]; then echo "" @@ -95,13 +117,19 @@ echo "" echo "$(timestamp) 🔨 Building on target..." # Frontend +section_start echo "$(timestamp) Building frontend (vue-tsc + vite)..." sshpass -p "$ARCHIPELAGO_PASSWORD" ssh $SSH_OPTS "$TARGET_HOST" "cd $TARGET_DIR/neode-ui && npm install --silent && npm run build" 2>&1 | sed 's/^/ /' +section_end -# Backend (if Rust is installed) -if sshpass -p "$ARCHIPELAGO_PASSWORD" ssh $SSH_OPTS "$TARGET_HOST" "source ~/.cargo/env 2>/dev/null && command -v cargo" >/dev/null 2>&1; then +# Backend (if Rust is installed) — skip with --frontend-only +if [ "$FRONTEND_ONLY" = true ]; then + echo "$(timestamp) Skipping backend build (--frontend-only)" +elif sshpass -p "$ARCHIPELAGO_PASSWORD" ssh $SSH_OPTS "$TARGET_HOST" "source ~/.cargo/env 2>/dev/null && command -v cargo" >/dev/null 2>&1; then + section_start echo "$(timestamp) Building backend (Rust release — this takes 1-2 min)..." sshpass -p "$ARCHIPELAGO_PASSWORD" ssh $SSH_OPTS "$TARGET_HOST" "source ~/.cargo/env && cd $TARGET_DIR/core && cargo build --release 2>&1" | sed 's/^/ /' + section_end else echo " ⚠️ Rust not installed on target, skipping backend build" fi @@ -110,13 +138,15 @@ if [ "$LIVE" = true ]; then echo "" echo "$(timestamp) 🚀 Deploying to live system..." - # Deploy backend (check if binary exists) - if sshpass -p "$ARCHIPELAGO_PASSWORD" ssh $SSH_OPTS "$TARGET_HOST" "[ -f $TARGET_DIR/core/target/release/archipelago ]" 2>/dev/null; then + # Deploy backend (check if binary exists) — skip with --frontend-only + if [ "$FRONTEND_ONLY" = true ]; then + echo "$(timestamp) Skipping backend deploy (--frontend-only)" + elif sshpass -p "$ARCHIPELAGO_PASSWORD" ssh $SSH_OPTS "$TARGET_HOST" "[ -f $TARGET_DIR/core/target/release/archipelago ]" 2>/dev/null; then echo "$(timestamp) Deploying backend binary..." sshpass -p "$ARCHIPELAGO_PASSWORD" ssh $SSH_OPTS "$TARGET_HOST" "sudo systemctl stop archipelago" sshpass -p "$ARCHIPELAGO_PASSWORD" ssh $SSH_OPTS "$TARGET_HOST" "sudo cp $TARGET_DIR/core/target/release/archipelago /usr/local/bin/" fi - + # Deploy frontend (preserve aiui/ and claude-login.html — they are NOT part of the neode-ui build) echo "$(timestamp) Deploying frontend..." sshpass -p "$ARCHIPELAGO_PASSWORD" ssh $SSH_OPTS "$TARGET_HOST" "sudo find /opt/archipelago/web-ui -mindepth 1 -maxdepth 1 ! -name 'aiui' ! -name 'claude-login.html' -exec rm -rf {} +" @@ -160,6 +190,9 @@ if [ "$LIVE" = true ]; then echo "$(timestamp) Setting up HTTPS for PWA install..." sshpass -p "$ARCHIPELAGO_PASSWORD" ssh $SSH_OPTS "$TARGET_HOST" "sudo bash $TARGET_DIR/scripts/setup-https-dev.sh" 2>&1 | sed 's/^/ /' || true + if [ "$FRONTEND_ONLY" = true ]; then + echo "$(timestamp) Skipping container rebuilds (--frontend-only)" + else # Rebuild and recreate LND UI container (port 8081 so Launch from UI and http://host:8081 both work) echo "$(timestamp) Rebuilding LND UI..." if sshpass -p "$ARCHIPELAGO_PASSWORD" ssh $SSH_OPTS "$TARGET_HOST" "cd $TARGET_DIR/docker/lnd-ui && (command -v podman >/dev/null 2>&1 && sudo podman build --no-cache -t lnd-ui:latest . || sudo docker build --no-cache -t lnd-ui:latest .)" 2>&1 | tail -12 | sed 's/^/ /'; then @@ -501,6 +534,7 @@ if [ "$LIVE" = true ]; then " 2>&1 | sed 's/^/ /' || true # Recreate Fedimint with FM_API_URL for Guardian UI (fixes "Api URL must be configured") + section_start echo "$(timestamp) Fixing Fedimint API URL..." TARGET_IP="$(echo "$TARGET_HOST" | cut -d@ -f2)" TIMEOUT_CMD="" @@ -530,6 +564,9 @@ if [ "$LIVE" = true ]; then break done " 2>&1 | sed 's/^/ /') || echo " (Fedimint fix timed out or skipped - run manually if needed)" + section_end + + fi # end FRONTEND_ONLY guard DEPLOY_END=$(date +%s) DEPLOY_ELAPSED=$((DEPLOY_END - DEPLOY_START))