Files
loki/scripts/deploy-hetzner.sh
T
Mao NakamotoandClaude Fable 5 4c8ab5425c feat(infra): exit Vercel — FleetCrown lives at fleetcrown.orangecat.ch
- swap dead fleetcrown.vercel.app for fleetcrown.orangecat.ch across src/,
  desktop/, README (Vercel team blocked for fair-use; serving 402s)
- scripts/deploy-hetzner.sh: build + rsync standalone + restart the
  fleetcrown-app unit on the bitbaum box (Caddy already vhosts the domain)
- brand.ts APP_DOMAIN remains the SSOT; historical thoughts essays keep the
  old domain as written

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-12 13:47:00 +02:00

44 lines
1.4 KiB
Bash

#!/usr/bin/env bash
# deploy-hetzner.sh — ship the production build to the bitbaum Hetzner box.
#
# The box serves FleetCrown at https://fleetcrown.orangecat.ch (Caddy →
# 127.0.0.1:4002, systemd unit fleetcrown-app). Box-side .env, launch.sh and
# backups/ are owned by the box and never touched by a deploy.
#
# Usage:
# bash scripts/deploy-hetzner.sh # build + rsync + restart
# bash scripts/deploy-hetzner.sh --no-build # rsync an existing build
set -euo pipefail
HOST="root@${HETZNER_IP:-167.233.22.31}"
APP_DIR="/opt/fleetcrown/app"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
STANDALONE="$PROJECT_DIR/.next/standalone"
if [ "${1:-}" != "--no-build" ]; then
(cd "$PROJECT_DIR" && npm run build)
fi
if [ ! -d "$STANDALONE/.next/static" ]; then
echo "✗ $STANDALONE missing static assets — run npm run build first" >&2
exit 1
fi
echo "→ rsync standalone → $HOST:$APP_DIR"
rsync -az --delete \
--exclude '.env' \
--exclude 'launch.sh' \
--exclude 'backups' \
"$STANDALONE/" "$HOST:$APP_DIR/"
echo "→ restart fleetcrown-app on box"
ssh "$HOST" "chown -R ubuntu:ubuntu $APP_DIR \
&& systemctl restart fleetcrown-app \
&& sleep 3 \
&& systemctl is-active fleetcrown-app \
&& curl -s -o /dev/null -w 'box app HTTP %{http_code}\n' http://127.0.0.1:4002/sign-in"
echo "✓ deployed $(cd "$PROJECT_DIR" && git rev-parse --short HEAD) to Hetzner"