Complete SSO role mapping and offline StateCorp release tooling
Some checks failed
State Corp Backend CI/CD / Quality gate (push) Failing after 9m34s
State Corp Backend CI/CD / Build linux/amd64 images once (push) Has been skipped
State Corp Backend CI/CD / Release dev (push) Has been skipped
State Corp Backend CI/CD / Refresh and release internal main (push) Has been skipped
State Corp Backend CI/CD / Release customer main (push) Has been skipped
Some checks failed
State Corp Backend CI/CD / Quality gate (push) Failing after 9m34s
State Corp Backend CI/CD / Build linux/amd64 images once (push) Has been skipped
State Corp Backend CI/CD / Release dev (push) Has been skipped
State Corp Backend CI/CD / Refresh and release internal main (push) Has been skipped
State Corp Backend CI/CD / Release customer main (push) Has been skipped
This commit is contained in:
70
deploy/offline/install.sh
Executable file
70
deploy/offline/install.sh
Executable file
@@ -0,0 +1,70 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
action=${1:-install}
|
||||
case "$action" in
|
||||
install|upgrade|rollback|health) ;;
|
||||
*) echo 'Usage: install.sh {install|upgrade|rollback|health}' >&2; exit 2 ;;
|
||||
esac
|
||||
|
||||
if [[ "$action" == health ]]; then
|
||||
docker compose --env-file .env -f compose.yml ps
|
||||
docker compose --env-file .env -f compose.yml exec -T web \
|
||||
curl -fsS http://localhost:8000/health/ready/
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ "$action" == rollback ]]; then
|
||||
if [[ ! -f .env.previous ]]; then
|
||||
echo 'No previous local image configuration available' >&2
|
||||
exit 2
|
||||
fi
|
||||
cp .env.previous .env
|
||||
chmod 600 .env
|
||||
docker compose --env-file .env -f compose.yml up -d --wait
|
||||
echo 'Image rollback complete. Database schema was not reversed.'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
sha256sum -c SHA256SUMS
|
||||
if [[ ! -f .env ]]; then
|
||||
cp env.example .env
|
||||
chmod 600 .env
|
||||
echo 'Edit .env with unique local credentials, then rerun install.sh' >&2
|
||||
exit 2
|
||||
fi
|
||||
if grep -q CHANGE_ME .env; then
|
||||
echo 'Replace all CHANGE_ME values in .env before installation' >&2
|
||||
exit 2
|
||||
fi
|
||||
if [[ "$action" == upgrade ]]; then
|
||||
cp .env .env.previous
|
||||
chmod 600 .env.previous
|
||||
# Keep local credentials and volumes, but select the images in this release.
|
||||
for key in STATE_WEB_IMAGE STATE_WORKER_IMAGE STATE_FRONTEND_IMAGE POSTGRES_IMAGE REDIS_IMAGE; do
|
||||
image=$(sed -n "s/^${key}=//p" env.example | head -n 1)
|
||||
if [[ -z "$image" ]] || ! grep -q "^${key}=" .env; then
|
||||
echo "Missing image pin: $key" >&2
|
||||
exit 2
|
||||
fi
|
||||
env_temp=$(mktemp .env.XXXXXX)
|
||||
sed "s|^${key}=.*|${key}=${image}|" .env > "$env_temp"
|
||||
chmod 600 "$env_temp"
|
||||
mv "$env_temp" .env
|
||||
done
|
||||
fi
|
||||
mkdir -p secrets
|
||||
if [[ ! -e secrets/sso-public.pem ]]; then
|
||||
: > secrets/sso-public.pem
|
||||
fi
|
||||
if grep -qi '^SSO_ENABLED=true$' .env && [[ ! -s secrets/sso-public.pem ]]; then
|
||||
echo 'SSO requires a real public PEM in secrets/sso-public.pem' >&2
|
||||
exit 2
|
||||
fi
|
||||
for archive in images/*.tar; do
|
||||
docker load -i "$archive"
|
||||
done
|
||||
docker compose --env-file .env -f compose.yml config -q
|
||||
docker compose --env-file .env -f compose.yml up -d --wait
|
||||
"$0" health
|
||||
Reference in New Issue
Block a user