feat: verfijn UX en borg Unraid deployment
deploy / deploy (push) Canceled after 0s

This commit is contained in:
Jens
2026-07-26 02:26:45 +02:00
parent 6c09d16a02
commit eea74f97ef
21 changed files with 1440 additions and 238 deletions
+37
View File
@@ -0,0 +1,37 @@
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")/.."
unraid_host="${UNRAID_SSH_HOST:-unraid-itworx}"
remote_root="${UNRAID_APP_ROOT:-/mnt/user/appdata/vacatureradar/source}"
archive_name="vacatureradar-deploy-$$.tar.gz"
local_archive="$(mktemp -t "${archive_name}.XXXXXX")"
trap 'rm -f "$local_archive"' EXIT
ssh_config="$(ssh -G "$unraid_host" 2>/dev/null)"
ssh_user="$(printf '%s\n' "$ssh_config" | awk '$1 == "user" { print $2; exit }')"
identity_file="$(printf '%s\n' "$ssh_config" | awk '$1 == "identityfile" { print $2; exit }')"
if [[ "$unraid_host" == *.* ]] || [[ "$ssh_user" != "root" ]] || [[ "$identity_file" == *"id_ed25519" ]]; then
echo "Onveilig of onvolledig Unraid-SSH-profiel: '$unraid_host'." >&2
echo "Gebruik een Host-alias met User root, IdentitiesOnly yes en een afzonderlijke deploysleutel." >&2
echo "Verwacht lokaal standaard: Host unraid-itworx / IdentityFile ~/.ssh/itworx_unraid_deploy" >&2
exit 2
fi
ssh -o BatchMode=yes -o ConnectTimeout=8 "$unraid_host" "test \"\$(id -un)\" = root && docker info >/dev/null"
git ls-files --cached --others --exclude-standard -z \
| tar --null --files-from=- --create --gzip --file="$local_archive"
scp -q "$local_archive" "$unraid_host:/tmp/$archive_name"
ssh "$unraid_host" "set -eu
mkdir -p '$remote_root'
tar -xzf '/tmp/$archive_name' -C '$remote_root'
rm -f '/tmp/$archive_name'
cd '$remote_root'
docker compose -f docker-compose.unraid.yml up -d --build
timeout 120 sh -c 'until docker inspect VacatureRadar --format=\"{{.State.Health.Status}}\" 2>/dev/null | grep -qx healthy; do sleep 3; done'
curl --fail --silent --show-error http://127.0.0.1:1226/health/ready/ >/dev/null
docker ps --filter name=VacatureRadar --format '{{.Names}} {{.Status}} {{.Image}}'"