check / check (push) Successful in 11s
The runtime stage declares a HEALTHCHECK that probes /.well-known/healthcheck.json with busybox wget. script/docker-smoke (make docker-smoke) builds the image with script/docker, starts it with a random PIXA_SIGNING_KEY, and passes only once Docker reports the container healthy within 30 seconds; the container is removed on exit and its log printed on failure. The Gitea workflow runs it after script/cibuild; it is not part of make check. It waits on Docker's health status instead of polling a published host port because the Gitea job runs in its own container on its own network, where such a port is not reachable at localhost. Model: opus-5-5
45 lines
1.4 KiB
Bash
Executable File
45 lines
1.4 KiB
Bash
Executable File
#!/bin/sh
|
|
# script/docker-smoke: build the Docker image, start it, and wait up to
|
|
# 30 seconds for its HEALTHCHECK to report healthy. Needs a Docker
|
|
# daemon, so it is not part of script/check; the Gitea workflow runs it
|
|
# after script/cibuild.
|
|
set -eu
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd -P)"
|
|
ROOT="$(cd "$SCRIPT_DIR/.." && pwd -P)"
|
|
|
|
main() {
|
|
cd "$ROOT"
|
|
"$SCRIPT_DIR/docker"
|
|
|
|
# A fresh random key: the container publishes no port and is
|
|
# removed on exit.
|
|
key="$(head -c 32 /dev/urandom | base64)"
|
|
|
|
# --health-interval=1s overrides the image's 30s interval so the
|
|
# first probe does not use up the whole wait.
|
|
cid="$(docker create --health-interval=1s \
|
|
-e PIXA_SIGNING_KEY="$key" "$("$SCRIPT_DIR/projectname")")"
|
|
# Remove the container on any exit; turning signals into exit makes
|
|
# an interrupted run clean up too.
|
|
trap 'docker rm -f "$cid" >/dev/null' EXIT
|
|
trap 'exit 1' HUP INT TERM
|
|
docker start "$cid" >/dev/null
|
|
|
|
deadline=$(($(date +%s) + 30))
|
|
while [ "$(date +%s)" -lt "$deadline" ]; do
|
|
health="$(docker inspect --format '{{.State.Health.Status}}' "$cid")"
|
|
if [ "$health" = healthy ]; then
|
|
echo "docker-smoke: container is healthy"
|
|
return 0
|
|
fi
|
|
sleep 1
|
|
done
|
|
|
|
echo "docker-smoke: container not healthy after 30 seconds; its log:" >&2
|
|
docker logs "$cid" >&2
|
|
return 1
|
|
}
|
|
|
|
main "$@"
|