SPB Git forge
15commits 1branches 0releases
29.7 MBsize
maindefault branch
10 days agolast push
TypeScript 36.3% Python 31.8% Go 18% JavaScript 9.8% Shell 1.9% SQL 1.4% CSS 0.5%
2.0 KB · 49 lines shellscript
Raw Blame History
1#!/usr/bin/env bash2# Deploy InternetPressure to BHS64b: rsync → build images on the server → compose up → migrate/seed → health.3#4#   deploy/bin/deploy.sh            full deploy (build + up + migrate + seed + health)5#   deploy/bin/deploy.sh up         compose up only (no rebuild)6#   deploy/bin/deploy.sh build      rsync + build images only7#   deploy/bin/deploy.sh status     docker compose ps + health8#   deploy/bin/deploy.sh logs [svc] follow logs9#   deploy/bin/deploy.sh route      (re)create the public route on the BHS64 gateway10#11# Prerequisites (one-off): deploy/bin/prep-server.sh (Docker, WireGuard wg1 peer to BHS64, ufw), deploy/.env on the server.12source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"1314cmd="${1:-full}"; shift || true1516health() {17  log "health via edge (through WireGuard from the gateway)"18  ssh -o BatchMode=yes "$IP_GATEWAY" "curl -s -m 10 -o /dev/null -w 'edge %{http_code} %{time_total}s\n' http://$IP_WG_IP:8350/api/v1/status; \19    curl -s -m 10 http://$IP_WG_IP:8350/api/v1/status | head -c 300; echo"20  log "public"21  curl -s -m 15 -o /dev/null -w "https://$IP_DOMAIN %{http_code} %{time_total}s\n" "https://$IP_DOMAIN/api/v1/status" || warn "public check failed (DNS/route?)"22}2324route() {25  log "route https://$IP_DOMAIN → $IP_WG_IP:8350 on $IP_GATEWAY"26  ssh -o BatchMode=yes "$IP_GATEWAY" "sudo tunnelctl add $IP_DOMAIN $IP_SERVER:8350 && sudo tunnelctl redirect internetpressure.io $IP_DOMAIN || true; sudo tunnelctl ls | grep -i internetpressure"27}2829case "$cmd" in30  full)31    sync_repo32    compose "build --pull api web"33    compose "up -d --remove-orphans"34    compose "run --rm migrate"35    compose "ps"36    sleep 537    health38    ;;39  build)  sync_repo; compose "build --pull api web" ;;40  up)     sync_repo; compose "up -d --remove-orphans"; compose "ps" ;;41  migrate) compose "run --rm migrate" ;;42  status) compose "ps"; health ;;43  logs)   compose "logs -f --tail=200 ${1:-}" ;;44  route)  route ;;45  restart) compose "restart ${1:-}" ;;46  *) die "unknown command $cmd" ;;47esac48ok "done"49