28 lines
1.3 KiB
Bash
Executable File
28 lines
1.3 KiB
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
|
|
root="${MOBILITYOPS_DEPLOY_ROOT:-/mnt/user/appdata/mobilityops}"
|
|
project="${COMPOSE_PROJECT_NAME:-mobilityops}"
|
|
revision="$(cat "$root/.deploy/source-revision")"
|
|
release_dir="$root/.deploy/releases/$revision"
|
|
[ -d "$release_dir" ] || { echo "Active release directory is missing" >&2; exit 1; }
|
|
|
|
history="$(tail -n 1 "$root/.deploy/release-history.log")"
|
|
# shellcheck disable=SC2086
|
|
set -- $history
|
|
[ "$1" = "$revision" ] || { echo "Release history does not match active revision" >&2; exit 1; }
|
|
export MOBILITYOPS_API_IMAGE="$2" MOBILITYOPS_WEB_IMAGE="$3"
|
|
compose="docker compose --env-file $root/.env -p $project -f $release_dir/compose.yaml -f $release_dir/compose.unraid.yaml -f $release_dir/compose.observability.yaml -f $release_dir/compose.release.yaml --profile observability"
|
|
|
|
$compose up --no-build -d db backup prometheus alertmanager grafana
|
|
for service in db backup prometheus alertmanager grafana; do
|
|
attempt=0
|
|
until status="$(docker inspect --format '{{if .State.Health}}{{.State.Health.Status}}{{else}}{{.State.Status}}{{end}}' "$project-$service-1" 2>/dev/null)" \
|
|
&& [ "$status" = "healthy" ]; do
|
|
attempt=$((attempt + 1))
|
|
[ "$attempt" -lt 60 ] || { echo "$service did not become healthy" >&2; exit 1; }
|
|
sleep 5
|
|
done
|
|
done
|
|
echo "Refreshed Fleet Ops infrastructure for $revision"
|