29 lines
1.4 KiB
Bash
29 lines
1.4 KiB
Bash
#!/usr/bin/env bash
|
|
#
|
|
# S-18a (#139): assert the Objecttypen API is healthy + its static token authenticates, against an
|
|
# ALREADY-RUNNING stack. Runs the check in a python:3-slim container on the stack network (the
|
|
# service is reached by container IP; the runner can't reach published ports — gitea-actions-gotchas.md
|
|
# §5/§6). Does NOT manage the stack lifecycle.
|
|
set -euo pipefail
|
|
|
|
here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
# The dev token provisioned by infra/objecttypen/setup_configuration/data.yaml.
|
|
TOKEN="${OBJECTTYPEN_TOKEN:-0123456789abcdef0123456789abcdef01234567}"
|
|
|
|
ot="$(docker ps -q --filter 'name=objecttypen' --filter 'health=healthy' | head -1)"
|
|
[ -n "$ot" ] || ot="$(docker ps -q --filter 'name=[-_]objecttypen[-_]' | head -1)"
|
|
[ -n "$ot" ] || { echo "ERROR: no running objecttypen container — bring the stack up first" >&2; exit 1; }
|
|
net="$(docker inspect -f '{{range $k,$_ := .NetworkSettings.Networks}}{{$k}}{{"\n"}}{{end}}' "$ot" | head -1)"
|
|
ip="$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$ot")"
|
|
echo ">> network=$net objecttypen=$ip"
|
|
|
|
cid="$(docker create --network "$net" \
|
|
-e "OBJECTTYPEN=http://$ip:8000" -e "OBJECTTYPEN_TOKEN=$TOKEN" \
|
|
-e "OBJECTTYPEN_TIMEOUT=${OBJECTTYPEN_TIMEOUT:-60}" \
|
|
python:3-slim python /objecttypen-check.py)"
|
|
docker cp "$here/objecttypen-check.py" "$cid:/objecttypen-check.py" >/dev/null
|
|
rc=0; docker start -a "$cid" || rc=$?
|
|
docker rm -f "$cid" >/dev/null
|
|
exit $rc
|