Files
geointel/scripts/deploy_tower.sh
T
Jens 19cd1054b2
GeoIntel release gates / Compile, test, contracts and builds (push) Failing after 24s
GeoIntel release gates / Python and npm vulnerability policy (push) Failing after 30s
GeoIntel release gates / GIS image, SBOM and container scan (push) Failing after 2m7s
Fix Tower release source and image identity
2026-08-23 22:38:42 +02:00

58 lines
2.2 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
REMOTE_HOST="${REMOTE_HOST:-root@192.168.10.150}"
REMOTE_PATH="${REMOTE_PATH:-/mnt/user/appdata/geointel}"
REMOTE_BRANCH="${REMOTE_BRANCH:-main}"
REMOTE_REPO="${REMOTE_REPO:-gitea-widefrog:Jens/geointel.git}"
SSH_KEY="${SSH_KEY:-$HOME/.ssh/itworx_unraid_deploy}"
FRONTEND_URL="${FRONTEND_URL:-http://192.168.10.150:1202}"
BOOTSTRAP="${DEPLOY_BOOTSTRAP:-0}"
DEPLOY_GEOINTEL_INSTALL_AI="${GEOINTEL_INSTALL_AI:-}"
ssh_opts=(-o BatchMode=yes -o StrictHostKeyChecking=accept-new)
if [[ -f "$SSH_KEY" ]]; then
ssh_opts+=(-i "$SSH_KEY")
fi
ssh "${ssh_opts[@]}" "$REMOTE_HOST" \
"REMOTE_PATH='$REMOTE_PATH' REMOTE_BRANCH='$REMOTE_BRANCH' REMOTE_REPO='$REMOTE_REPO' FRONTEND_URL='$FRONTEND_URL' DEPLOY_BOOTSTRAP='$BOOTSTRAP' DEPLOY_GEOINTEL_INSTALL_AI='$DEPLOY_GEOINTEL_INSTALL_AI' bash -s" <<'REMOTE_SCRIPT'
set -euo pipefail
cd "$REMOTE_PATH"
git config --global --add safe.directory "$REMOTE_PATH"
if [[ ! -d .git ]]; then
if [[ "$DEPLOY_BOOTSTRAP" != "1" ]]; then
echo "No git checkout found in $REMOTE_PATH."
echo "Re-run with DEPLOY_BOOTSTRAP=1 for the first deployment bootstrap."
exit 2
fi
git init
git remote add origin "$REMOTE_REPO"
fi
if git remote get-url origin >/dev/null 2>&1; then
git remote set-url origin "$REMOTE_REPO"
else
git remote add origin "$REMOTE_REPO"
fi
git fetch origin "$REMOTE_BRANCH"
git checkout -B "$REMOTE_BRANCH" "origin/$REMOTE_BRANCH"
# Remove only untracked source files that can enter the image. Persistent
# runtime roots (.env, storage, models and postgres-data) are deliberately not
# in this scoped clean list.
git clean -fd -- backend frontend deploy scripts fixtures tests contracts demo
chmod +x scripts/*.sh backend/docker_start.sh deploy/unraid/*.sh || true
# Persistent runtime roots can legitimately contain untracked files. The
# deploy checkout nevertheless has an exact, freshly fetched source revision
# because every image-bearing source path was reset and cleaned above.
DEPLOY_BUILD_SHA="$(git rev-parse HEAD)"
GEOINTEL_BUILD_SHA="$DEPLOY_BUILD_SHA" \
FRONTEND_URL="$FRONTEND_URL" \
DEPLOY_GEOINTEL_INSTALL_AI="${DEPLOY_GEOINTEL_INSTALL_AI:-}" \
bash deploy/unraid/deploy-release.sh
REMOTE_SCRIPT