-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·70 lines (63 loc) · 2.53 KB
/
Copy pathdeploy.sh
File metadata and controls
executable file
·70 lines (63 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env bash
# Sentrix Explorer V2 — release deployment.
#
# Builds both networks (one binary per network, since SENTRIX_NETWORK is
# compile-time baked) and ships them to the production host. Run from
# the build machine; never from a validator host.
#
# Pre-flight on the build machine:
# - cargo, cargo-leptos, rustup target wasm32-unknown-unknown
# - protoc ≥ 3.15
#
# Pre-flight on the production host:
# - /etc/systemd/system/sentrix-explorer@.service installed
# - /var/www/sentrix-explorer/{mainnet,testnet}/ exist + writable
# - caddy block from deploy/Caddyfile merged into /etc/caddy/Caddyfile
set -euo pipefail
DEST_HOST="${DEST_HOST:?DEST_HOST must be set — production host IP/DNS}"
# Production runs the explorer under a non-privileged service user; ssh
# as that user so rsync preserves the file ownership systemd expects.
# Per-instance restart needs root via sudo (see `restart()` below) — the
# operator's NOPASSWD sudoers entry makes that interactive-free.
DEST_USER="${DEST_USER:-sentriscloud}"
DEST_ROOT="${DEST_ROOT:-/var/www/sentrix-explorer}"
build_for() {
local network="$1"
echo "── building $network bundle ─────────────────────────"
SENTRIX_NETWORK="$network" cargo leptos build --release
# cargo-leptos drops:
# target/release/sentrix-explorer-v2 (axum SSR binary)
# target/site/ (HTML + /pkg WASM + assets)
# Stage them into a per-network directory before rsync so two
# release artifacts don't clobber each other in target/.
local stage="target/dist/$network"
rm -rf "$stage"
mkdir -p "$stage"
cp target/release/sentrix-explorer-v2 "$stage/"
cp -r target/site "$stage/"
}
ship() {
local network="$1"
local stage="target/dist/$network"
local dest="$DEST_ROOT/$network"
echo "── shipping $network → $DEST_USER@$DEST_HOST:$dest ──"
ssh "$DEST_USER@$DEST_HOST" "mkdir -p $dest"
rsync -avz --delete "$stage/" "$DEST_USER@$DEST_HOST:$dest/"
}
restart() {
local network="$1"
echo "── restarting sentrix-explorer@$network ─────────────"
ssh "$DEST_USER@$DEST_HOST" "sudo systemctl restart sentrix-explorer@$network"
}
main() {
for net in mainnet testnet; do
build_for "$net"
ship "$net"
restart "$net"
done
echo
echo "✓ deployment complete"
echo " mainnet → https://scan.sentriscloud.com"
echo " testnet → https://scan-testnet.sentriscloud.com"
}
main "$@"