Freshness diagnostics API, UI trust notes, mission control/stats updates, and deploy scripts.

Made-with: Cursor
This commit is contained in:
defiQUG
2026-04-12 06:33:54 -07:00
parent f46bd213ba
commit ee71f098ab
63 changed files with 5163 additions and 826 deletions

View File

@@ -177,6 +177,21 @@ from pathlib import Path
import re
path = Path('/etc/nginx/sites-available/blockscout')
text = path.read_text()
stats_block = ''' # Explorer stats override: keep freshness/completeness metadata on the explorer-owned backend.
location = /api/v2/stats {
proxy_pass http://127.0.0.1:8081/api/v2/stats;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 60s;
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS";
add_header Access-Control-Allow-Headers "Content-Type, Authorization";
}
'''
explorer_block = ''' # Explorer backend API (auth, features, AI, explorer-owned v1 helpers)
location /explorer-api/v1/ {
proxy_pass http://127.0.0.1:8081/api/v1/;
@@ -195,6 +210,58 @@ explorer_block = ''' # Explorer backend API (auth, features, AI, explorer-own
escaped_explorer_block = explorer_block.replace('$', '\\$')
if escaped_explorer_block in text:
text = text.replace(escaped_explorer_block, explorer_block)
escaped_stats_block = stats_block.replace('$', '\\$')
if escaped_stats_block in text:
text = text.replace(escaped_stats_block, stats_block)
def dedupe_named_location_block(text: str, marker: str, next_markers: list[str]) -> str:
first = text.find(marker)
if first == -1:
return text
second = text.find(marker, first + len(marker))
if second == -1:
return text
next_positions = [text.find(candidate, second) for candidate in next_markers]
next_positions = [pos for pos in next_positions if pos != -1]
if not next_positions:
return text
return text[:first] + text[second:min(next_positions)] + text[min(next_positions):]
text = dedupe_named_location_block(
text,
' # Explorer backend API (auth, features, AI, explorer-owned v1 helpers)\n',
[
' # Blockscout API endpoint - MUST come before the redirect location\n',
' # API endpoint - MUST come before the redirect location\n',
' # Token-aggregation API for the explorer SPA live route-tree and pool intelligence.\n',
' # Token-aggregation API at /api/v1/ for the Snap site. Service runs on port 3001.\n',
],
)
text = dedupe_named_location_block(
text,
' # Explorer stats override: keep freshness/completeness metadata on the explorer-owned backend.\n',
[
' # Explorer backend API (auth, features, AI, explorer-owned v1 helpers)\n',
' # Blockscout API endpoint - MUST come before the redirect location\n',
' # API endpoint - MUST come before the redirect location\n',
' # Token-aggregation API for the explorer SPA live route-tree and pool intelligence.\n',
' # Token-aggregation API at /api/v1/ for the Snap site. Service runs on port 3001.\n',
],
)
text = dedupe_named_location_block(
text,
' # Enriched explorer stats come from the Go-side API on 8081.\n',
[
' # Explorer stats override: keep freshness/completeness metadata on the explorer-owned backend.\n',
' # Explorer backend API (auth, features, AI, explorer-owned v1 helpers)\n',
' # Blockscout API endpoint - MUST come before the redirect location\n',
' # API endpoint - MUST come before the redirect location\n',
' # Token-aggregation API for the explorer SPA live route-tree and pool intelligence.\n',
' # Token-aggregation API at /api/v1/ for the Snap site. Service runs on port 3001.\n',
],
)
legacy_patterns = [
r"\n\s*# Explorer AI endpoints on the explorer backend service \(HTTP\)\n\s*location /api/v1/ai/ \{.*?\n\s*\}\n",
@@ -206,6 +273,12 @@ for pattern in legacy_patterns:
http_needle = ' # Blockscout API endpoint - MUST come before the redirect location\n'
legacy_http_needle = ' # API endpoint - MUST come before the redirect location\n'
if stats_block not in text:
if http_needle in text:
text = text.replace(http_needle, stats_block + http_needle, 1)
elif legacy_http_needle in text:
text = text.replace(legacy_http_needle, stats_block + ' # Blockscout API endpoint - MUST come before the redirect location\n', 1)
if explorer_block not in text:
if http_needle in text:
text = text.replace(http_needle, explorer_block + http_needle, 1)
@@ -213,6 +286,8 @@ if explorer_block not in text:
text = text.replace(legacy_http_needle, explorer_block + ' # Blockscout API endpoint - MUST come before the redirect location\n', 1)
https_needle = ' # Token-aggregation API for the explorer SPA live route-tree and pool intelligence.\n'
if stats_block not in text[text.find('# HTTPS server - Blockscout Explorer'):]:
text = text.replace(' # Token-aggregation API at /api/v1/ for the Snap site. Service runs on port 3001.\n location /api/v1/ {\n proxy_pass http://127.0.0.1:3001/api/v1/;\n proxy_http_version 1.1;\n proxy_set_header Host $host;\n proxy_set_header X-Real-IP $remote_addr;\n proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n proxy_set_header X-Forwarded-Proto $scheme;\n proxy_read_timeout 60s;\n add_header Access-Control-Allow-Origin *;\n }\n\n', stats_block + ' # Token-aggregation API at /api/v1/ for the Snap site. Service runs on port 3001.\n location /api/v1/ {\n proxy_pass http://127.0.0.1:3001/api/v1/;\n proxy_http_version 1.1;\n proxy_set_header Host $host;\n proxy_set_header X-Real-IP $remote_addr;\n proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n proxy_set_header X-Forwarded-Proto $scheme;\n proxy_read_timeout 60s;\n add_header Access-Control-Allow-Origin *;\n }\n\n', 1)
if explorer_block not in text[text.find('# HTTPS server - Blockscout Explorer'):]:
text = text.replace(' # Token-aggregation API at /api/v1/ for the Snap site. Service runs on port 3001.\n location /api/v1/ {\n proxy_pass http://127.0.0.1:3001/api/v1/;\n proxy_http_version 1.1;\n proxy_set_header Host $host;\n proxy_set_header X-Real-IP $remote_addr;\n proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n proxy_set_header X-Forwarded-Proto $scheme;\n proxy_read_timeout 60s;\n add_header Access-Control-Allow-Origin *;\n }\n\n', explorer_block, 1)
path.write_text(text)

281
scripts/deploy-frontend-to-vmid5000.sh Executable file → Normal file
View File

@@ -1,278 +1,19 @@
#!/bin/bash
#!/usr/bin/env bash
# Deploy legacy static explorer frontend to VMID 5000
# This copies the old SPA assets into /var/www/html/.
# For the current Next.js frontend, use ./scripts/deploy-next-frontend-to-vmid5000.sh
#
# Optional: for air-gapped Mermaid on chain138-command-center.html, run:
# bash explorer-monorepo/scripts/vendor-mermaid-for-command-center.sh
# then switch the script src in chain138-command-center.html to /thirdparty/mermaid.min.js
# Deprecated legacy static frontend deploy shim.
# The canonical deployment path is the Next.js standalone frontend.
set -euo pipefail
VMID=5000
VM_IP="192.168.11.140"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
FRONTEND_SOURCE="${REPO_ROOT}/explorer-monorepo/frontend/public/index.html"
[ -f "$FRONTEND_SOURCE" ] || FRONTEND_SOURCE="${SCRIPT_DIR}/../frontend/public/index.html"
FRONTEND_PUBLIC="$(dirname "$FRONTEND_SOURCE")"
PROXMOX_R630_02="${PROXMOX_HOST_R630_02:-192.168.11.12}"
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
CANONICAL_SCRIPT="$REPO_ROOT/scripts/deploy-next-frontend-to-vmid5000.sh"
echo "=========================================="
echo "Deploying Legacy Static Explorer Frontend"
echo "=========================================="
echo "This script is deprecated."
echo "The legacy static SPA deployment path is no longer supported as a primary deploy target."
echo ""
# Check if running from Proxmox host or inside container
if [ -f "/proc/1/cgroup" ] && grep -q "lxc" /proc/1/cgroup 2>/dev/null; then
EXEC_PREFIX=""
echo "Running inside VMID 5000"
DEPLOY_METHOD="direct"
run_in_vm() { "$@"; }
elif command -v pct &>/dev/null; then
EXEC_PREFIX="pct exec $VMID --"
echo "Running from Proxmox host, executing in VMID 5000"
DEPLOY_METHOD="pct"
run_in_vm() { pct exec $VMID -- "$@"; }
else
echo "Running from remote: will scp + SSH to $PROXMOX_R630_02 and deploy to VMID $VMID"
DEPLOY_METHOD="remote"
EXEC_PREFIX=""
run_in_vm() { ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no root@${PROXMOX_R630_02} "pct exec $VMID -- $*"; }
fi
# Step 1: Check if frontend file exists
if [ ! -f "$FRONTEND_SOURCE" ]; then
echo "❌ Frontend file not found: $FRONTEND_SOURCE"
echo "Please ensure you're running from the correct directory"
exit 1
fi
echo "✅ Frontend source found: $FRONTEND_SOURCE"
echo ""
# Step 2: Create /var/www/html if it doesn't exist
echo "=== Step 2: Preparing deployment directory ==="
run_in_vm "mkdir -p /var/www/html"
run_in_vm "chown -R www-data:www-data /var/www/html" 2>/dev/null || true
echo "✅ Directory prepared"
echo ""
# Step 3: Backup existing frontend
echo "=== Step 3: Backing up existing frontend ==="
run_in_vm "bash -c 'if [ -f /var/www/html/index.html ]; then cp /var/www/html/index.html /var/www/html/index.html.backup.\$(date +%Y%m%d_%H%M%S); echo \"✅ Backup created\"; else echo \"⚠️ No existing frontend to backup\"; fi'"
echo ""
# Step 4: Deploy frontend
echo "=== Step 4: Deploying frontend ==="
if [ "$DEPLOY_METHOD" = "direct" ]; then
# Running inside VMID 5000
cp "$FRONTEND_SOURCE" /var/www/html/index.html
chown www-data:www-data /var/www/html/index.html 2>/dev/null || true
echo "✅ Frontend deployed"
elif [ "$DEPLOY_METHOD" = "remote" ]; then
scp -o ConnectTimeout=10 -o StrictHostKeyChecking=no "$FRONTEND_SOURCE" root@${PROXMOX_R630_02}:/tmp/explorer-index.html
ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no root@${PROXMOX_R630_02} "pct push $VMID /tmp/explorer-index.html /var/www/html/index.html --perms 0644 && pct exec $VMID -- chown www-data:www-data /var/www/html/index.html"
echo "✅ Frontend deployed via $PROXMOX_R630_02"
else
# Running from Proxmox host
pct push $VMID "$FRONTEND_SOURCE" /var/www/html/index.html
$EXEC_PREFIX chown www-data:www-data /var/www/html/index.html 2>/dev/null || true
echo "✅ Frontend deployed"
fi
echo ""
# Step 4b: Deploy favicon and apple-touch-icon
echo "=== Step 4b: Deploying icons ==="
for ASSET in explorer-spa.js chain138-command-center.html apple-touch-icon.png favicon.ico; do
SRC="${FRONTEND_PUBLIC}/${ASSET}"
if [ ! -f "$SRC" ]; then
echo "⚠️ Skip $ASSET (not found)"
continue
fi
if [ "$DEPLOY_METHOD" = "direct" ]; then
cp "$SRC" "/var/www/html/$ASSET"
chown www-data:www-data "/var/www/html/$ASSET" 2>/dev/null || true
echo "$ASSET deployed"
elif [ "$DEPLOY_METHOD" = "remote" ]; then
scp -o ConnectTimeout=10 -o StrictHostKeyChecking=no "$SRC" root@${PROXMOX_R630_02}:/tmp/"$ASSET"
ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no root@${PROXMOX_R630_02} "pct push $VMID /tmp/$ASSET /var/www/html/$ASSET --perms 0644 && pct exec $VMID -- chown www-data:www-data /var/www/html/$ASSET"
echo "$ASSET deployed via $PROXMOX_R630_02"
else
pct push $VMID "$SRC" "/var/www/html/$ASSET"
$EXEC_PREFIX chown www-data:www-data "/var/www/html/$ASSET" 2>/dev/null || true
echo "$ASSET deployed"
fi
done
# Optional local Mermaid (~3 MB) for command center when jsDelivr/CSP is blocked
MERMAID_SRC="${FRONTEND_PUBLIC}/thirdparty/mermaid.min.js"
if [ -f "$MERMAID_SRC" ]; then
echo "=== Step 4b2: Deploying thirdparty/mermaid.min.js (local vendored) ==="
if [ "$DEPLOY_METHOD" = "direct" ]; then
mkdir -p /var/www/html/thirdparty
cp "$MERMAID_SRC" /var/www/html/thirdparty/mermaid.min.js
chown www-data:www-data /var/www/html/thirdparty/mermaid.min.js 2>/dev/null || true
echo "✅ thirdparty/mermaid.min.js deployed"
elif [ "$DEPLOY_METHOD" = "remote" ]; then
scp -o ConnectTimeout=10 -o StrictHostKeyChecking=no "$MERMAID_SRC" root@${PROXMOX_R630_02}:/tmp/mermaid.min.js
ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no root@${PROXMOX_R630_02} "pct exec $VMID -- mkdir -p /var/www/html/thirdparty && pct push $VMID /tmp/mermaid.min.js /var/www/html/thirdparty/mermaid.min.js --perms 0644 && pct exec $VMID -- chown www-data:www-data /var/www/html/thirdparty/mermaid.min.js"
echo "✅ thirdparty/mermaid.min.js deployed via $PROXMOX_R630_02"
else
$EXEC_PREFIX mkdir -p /var/www/html/thirdparty
pct push $VMID "$MERMAID_SRC" /var/www/html/thirdparty/mermaid.min.js
$EXEC_PREFIX chown www-data:www-data /var/www/html/thirdparty/mermaid.min.js 2>/dev/null || true
echo "✅ thirdparty/mermaid.min.js deployed"
fi
echo ""
else
echo " Skip thirdparty/mermaid.min.js (run scripts/vendor-mermaid-for-command-center.sh if CSP/offline needs local Mermaid)"
echo ""
fi
echo "=== Step 4c: Deploying /config JSON (topology, verify example) ==="
run_in_vm "mkdir -p /var/www/html/config"
for CFG in topology-graph.json mission-control-verify.example.json; do
CFG_SRC="${FRONTEND_PUBLIC}/config/${CFG}"
if [ ! -f "$CFG_SRC" ]; then
echo "⚠️ Skip config/$CFG (not found)"
continue
fi
if [ "$DEPLOY_METHOD" = "direct" ]; then
cp "$CFG_SRC" "/var/www/html/config/$CFG"
chown www-data:www-data "/var/www/html/config/$CFG" 2>/dev/null || true
echo "✅ config/$CFG deployed"
elif [ "$DEPLOY_METHOD" = "remote" ]; then
scp -o ConnectTimeout=10 -o StrictHostKeyChecking=no "$CFG_SRC" root@${PROXMOX_R630_02}:/tmp/explorer-cfg-"$CFG"
ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no root@${PROXMOX_R630_02} "pct push $VMID /tmp/explorer-cfg-$CFG /var/www/html/config/$CFG --perms 0644 && pct exec $VMID -- chown www-data:www-data /var/www/html/config/$CFG"
echo "✅ config/$CFG deployed via $PROXMOX_R630_02"
else
pct push $VMID "$CFG_SRC" "/var/www/html/config/$CFG"
$EXEC_PREFIX chown www-data:www-data "/var/www/html/config/$CFG" 2>/dev/null || true
echo "✅ config/$CFG deployed"
fi
done
echo ""
# Step 5 (remote): Apply nginx config so /favicon.ico and /apple-touch-icon.png are served
if [ "$DEPLOY_METHOD" = "remote" ]; then
echo "=== Step 5 (remote): Applying nginx config for icons ==="
FIX_NGINX_SCRIPT="${REPO_ROOT}/explorer-monorepo/scripts/fix-nginx-serve-custom-frontend.sh"
if [ -f "$FIX_NGINX_SCRIPT" ]; then
scp -o ConnectTimeout=10 -o StrictHostKeyChecking=no "$FIX_NGINX_SCRIPT" root@${PROXMOX_R630_02}:/tmp/fix-nginx-explorer.sh
ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no root@${PROXMOX_R630_02} "pct push $VMID /tmp/fix-nginx-explorer.sh /tmp/fix-nginx-explorer.sh --perms 0755 && pct exec $VMID -- /tmp/fix-nginx-explorer.sh"
echo "✅ Nginx config applied (favicon and apple-touch-icon locations)"
else
echo "⚠️ Nginx fix script not found ($FIX_NGINX_SCRIPT); icons may still 404 until nginx is updated on VM"
fi
echo ""
fi
# Step 5 (local/pct): Update nginx configuration
if [ "$DEPLOY_METHOD" != "remote" ]; then
echo "=== Step 5: Updating nginx configuration ==="
$EXEC_PREFIX bash << 'NGINX_UPDATE'
CONFIG_FILE="/etc/nginx/sites-available/blockscout"
# Check if config exists
if [ ! -f "$CONFIG_FILE" ]; then
echo "❌ Nginx config not found: $CONFIG_FILE"
exit 1
fi
# Update HTTPS server block to serve static files for root, proxy API
sed -i '/location \/ {/,/}/c\
# Serve custom frontend for root path\
location = / {\
root /var/www/html;\
try_files /index.html =404;\
}\
\
# Serve static assets\
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {\
root /var/www/html;\
expires 1y;\
add_header Cache-Control "public, immutable";\
}\
\
# Proxy Blockscout UI if needed (fallback)\
location /blockscout/ {\
proxy_pass http://127.0.0.1:4000/;\
proxy_http_version 1.1;\
proxy_set_header Host $host;\
proxy_set_header X-Real-IP $remote_addr;\
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\
proxy_set_header X-Forwarded-Proto $scheme;\
}' "$CONFIG_FILE"
echo "✅ Nginx config updated"
NGINX_UPDATE
# Step 6: Test and restart nginx
echo ""
echo "=== Step 6: Testing and restarting nginx ==="
if $EXEC_PREFIX nginx -t; then
echo "✅ Configuration valid"
$EXEC_PREFIX systemctl restart nginx
echo "✅ Nginx restarted"
else
echo "❌ Configuration has errors"
exit 1
fi
echo ""
fi
# Step 7: Verify deployment
echo "=== Step 7: Verifying deployment ==="
sleep 2
run_in_vm() {
if [ "$DEPLOY_METHOD" = "remote" ]; then
ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no root@${PROXMOX_R630_02} "pct exec $VMID -- $1"
else
$EXEC_PREFIX $1
fi
}
# Check if file exists
if run_in_vm "test -f /var/www/html/index.html"; then
echo "✅ Frontend file exists"
# Check if it contains expected content
if run_in_vm "grep -qiE 'SolaceScan|Chain 138 Explorer by DBIS' /var/www/html/index.html"; then
echo "✅ Frontend content verified"
else
echo "⚠️ Frontend file exists but content may be incorrect"
fi
else
echo "❌ Frontend file not found"
exit 1
fi
# Test HTTP endpoint (non-fatal: do not exit on failure)
HTTP_RESPONSE=$(run_in_vm "curl -s --max-time 5 http://localhost/ 2>/dev/null | head -5" 2>/dev/null) || true
if echo "$HTTP_RESPONSE" | grep -qiE "SolaceScan|Chain 138 Explorer by DBIS|<!DOCTYPE html"; then
echo "✅ Frontend is accessible via nginx"
else
echo "⚠️ Frontend may not be accessible (check nginx config)"
echo "Response: $HTTP_RESPONSE"
fi
echo ""
echo "=========================================="
echo "Deployment Complete!"
echo "=========================================="
echo ""
echo "Note: this is the legacy static SPA deployment path."
echo "For the current Next.js frontend, use:"
echo " ./scripts/deploy-next-frontend-to-vmid5000.sh"
echo ""
echo "Frontend should now be accessible at:"
echo " - http://$VM_IP/"
echo " - https://explorer.d-bis.org/"
echo ""
echo "To view logs:"
echo " tail -f /var/log/nginx/blockscout-access.log"
echo " tail -f /var/log/nginx/blockscout-error.log"
echo "Use the canonical Next.js frontend deploy instead:"
echo " bash $CANONICAL_SCRIPT"
echo ""
echo "The static compatibility assets remain in-repo for fallback/reference purposes only."
exit 1

View File

@@ -22,6 +22,7 @@ VERIFY_SCRIPT="${WORKSPACE_ROOT}/scripts/verify/check-explorer-e2e.sh"
RELEASE_ID="$(date +%Y%m%d_%H%M%S)"
TMP_DIR="$(mktemp -d)"
ARCHIVE_NAME="solacescanscout-next-${RELEASE_ID}.tar"
BUILD_LOCK_DIR="${FRONTEND_ROOT}/.next-build-lock"
STATIC_SYNC_FILES=(
"index.html"
"docs.html"
@@ -35,6 +36,9 @@ STATIC_SYNC_FILES=(
)
cleanup() {
if [[ -d "$BUILD_LOCK_DIR" ]]; then
rmdir "$BUILD_LOCK_DIR" 2>/dev/null || true
fi
rm -rf "$TMP_DIR"
}
trap cleanup EXIT
@@ -82,8 +86,25 @@ echo "Frontend root: $FRONTEND_ROOT"
echo "Release: $RELEASE_ID"
echo ""
acquire_build_lock() {
local attempts=0
until mkdir "$BUILD_LOCK_DIR" 2>/dev/null; do
attempts=$((attempts + 1))
if (( attempts == 1 )); then
echo "Waiting for another frontend build to finish..."
fi
if (( attempts >= 120 )); then
echo "Timed out waiting for frontend build lock: $BUILD_LOCK_DIR" >&2
exit 1
fi
sleep 1
done
}
if [[ "${SKIP_BUILD:-0}" != "1" ]]; then
echo "== Building frontend =="
acquire_build_lock
rm -rf "${FRONTEND_ROOT}/.next"
(cd "$FRONTEND_ROOT" && npm run build)
echo ""
fi

73
scripts/deploy.sh Executable file → Normal file
View File

@@ -1,72 +1,19 @@
#!/usr/bin/env bash
# Deploy the legacy static explorer frontend to production
# For the current Next.js frontend deployment, use scripts/deploy-next-frontend-to-vmid5000.sh
# Deprecated legacy static frontend deploy shim.
# Kept only so older runbooks fail clearly instead of redeploying the wrong surface.
set -euo pipefail
IP="${IP:-192.168.11.140}"
DOMAIN="${DOMAIN:-explorer.d-bis.org}"
PASSWORD="${PASSWORD:-L@kers2010}"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
NC='\033[0m'
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
log_success() { echo -e "${GREEN}[✓]${NC} $1"; }
log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
log_step() { echo -e "${CYAN}[STEP]${NC} $1"; }
# Get script directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
CANONICAL_SCRIPT="$REPO_ROOT/scripts/deploy-next-frontend-to-vmid5000.sh"
echo "════════════════════════════════════════════════════════"
echo "Deploy Legacy Chain 138 Explorer Frontend"
echo "════════════════════════════════════════════════════════"
echo "This script is deprecated."
echo "It previously deployed the legacy static SPA, which is no longer the supported production frontend."
echo ""
log_warn "This script deploys the legacy static SPA."
log_warn "For the current Next.js frontend, use ./scripts/deploy-next-frontend-to-vmid5000.sh"
echo ""
# Check if files exist
if [ ! -f "$REPO_ROOT/frontend/public/index.html" ]; then
log_error "Frontend file not found: $REPO_ROOT/frontend/public/index.html"
exit 1
fi
log_step "Step 1: Backing up current deployment..."
sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no root@"$IP" \
"cp /var/www/html/index.html /var/www/html/index.html.backup.$(date +%Y%m%d_%H%M%S) 2>/dev/null || true"
log_success "Backup created"
log_step "Step 2: Deploying frontend files..."
sshpass -p "$PASSWORD" scp -o StrictHostKeyChecking=no \
"$REPO_ROOT/frontend/public/index.html" \
root@"$IP":/var/www/html/index.html
[ -f "$REPO_ROOT/frontend/public/explorer-spa.js" ] && sshpass -p "$PASSWORD" scp -o StrictHostKeyChecking=no \
"$REPO_ROOT/frontend/public/explorer-spa.js" \
root@"$IP":/var/www/html/explorer-spa.js
log_success "Frontend deployed"
log_step "Step 3: Verifying deployment..."
sleep 2
if curl -k -sI "https://$DOMAIN/" 2>&1 | grep -qi "HTTP.*200"; then
log_success "Deployment verified - Explorer is accessible"
else
log_warn "Deployment completed but verification failed - check manually"
fi
echo ""
log_success "Deployment complete!"
echo ""
log_info "Explorer URL: https://$DOMAIN/"
log_info "To rollback: ssh root@$IP 'cp /var/www/html/index.html.backup.* /var/www/html/index.html'"
echo "Use the canonical Next.js frontend deploy instead:"
echo " bash $CANONICAL_SCRIPT"
echo ""
echo "If you are following an older runbook, update it to the canonical deploy path."
exit 1

View File

@@ -393,12 +393,12 @@ if [ -f /var/www/html/index.html ]; then
else
echo "⚠️ Frontend file exists but may not be the custom one"
echo " Deploy the custom frontend using:"
echo " ./scripts/deploy-frontend-to-vmid5000.sh"
echo " ./scripts/deploy-next-frontend-to-vmid5000.sh"
fi
else
echo "⚠️ Custom frontend not found at /var/www/html/index.html"
echo " Deploy the custom frontend using:"
echo " ./scripts/deploy-frontend-to-vmid5000.sh"
echo " ./scripts/deploy-next-frontend-to-vmid5000.sh"
fi
# Test HTTP endpoint (non-fatal: do not exit on curl/grep failure)
@@ -418,6 +418,6 @@ echo "Nginx Configuration Updated!"
echo "=========================================="
echo ""
echo "Next steps:"
echo "1. Deploy custom frontend: ./scripts/deploy-frontend-to-vmid5000.sh"
echo "2. Or manually copy: cp explorer-monorepo/frontend/public/index.html /var/www/html/index.html"
echo "1. Deploy the canonical Next frontend: ./scripts/deploy-next-frontend-to-vmid5000.sh"
echo "2. Verify the public surface after nginx/NPMplus cutover"
echo ""