Some checks failed
Forgejo Android APK / Root app tests (push) Successful in 47s
Forgejo Docker Build / Root app tests (push) Successful in 48s
Forgejo Android APK / Build signed APK (push) Successful in 2m22s
Forgejo Docker Build / Build Docker image (push) Successful in 11s
Forgejo Docker Build / Deploy to the host (push) Failing after 2s
scripts/deploy.sh landed on 2026-09-11 as "a deploy you can repeat, and prove afterwards". It moves the PED_AI_IMAGE pin, waits for health, reads /api/build to find out which revision is actually serving, and rolls back when that is not the revision asked for. Its own comment says it: "Healthy is not the same as running what was asked for." No doc mentioned it. Both deployment.md and DEVELOPMENT.md instead showed `build-image.sh` then `docker compose up -d --no-build` then `curl /api/health` — a sequence that moves no pin and proves no revision. Following it deployed nothing four times in one session, eventually reverting the app by 31 commits and removing a feature, which was then reported as a bug. Both docs now lead with deploy.sh and say why `up` by hand is not a deploy. Also replaced yesterday's build-image.sh warning, which told the operator to `sed` the pin themselves. That reimplemented, badly, one of the three things deploy.sh already does — and it was written while auditing these very files without noticing the script was there. It now prints the deploy.sh line to run. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Dv6sqaY6Vq3ChZHMem3cnU
69 lines
2.8 KiB
Bash
Executable file
69 lines
2.8 KiB
Bash
Executable file
#!/bin/sh
|
|
# Build only; this never starts services.
|
|
#
|
|
# The revision is validated and baked into the image (BUILD_ID + the OCI
|
|
# revision label), so the result can always be traced back to a commit and
|
|
# /api/build can report it at runtime. Plain `docker compose build` does not set
|
|
# GIT_REVISION and produces an image labelled "unknown" — which is why this is
|
|
# the supported way to build.
|
|
#
|
|
# The image is tagged twice: ped-ai-local:<revision> is immutable and is what a
|
|
# deploy should name, ped-ai-local:latest is the convenience pointer.
|
|
set -eu
|
|
cd "$(dirname "$0")/.."
|
|
if [ -e .git ]; then
|
|
GIT_REVISION=$(env -i PATH="$PATH" HOME="${HOME:-}" git rev-parse --verify 'HEAD^{commit}')
|
|
printf '%s\n' "$GIT_REVISION" | grep -Eq '^[0-9a-f]{40}$' || {
|
|
echo 'Expected a full lowercase Git SHA' >&2
|
|
exit 1
|
|
}
|
|
else
|
|
GIT_REVISION=unknown
|
|
echo 'Unversioned development build: revision unknown' >&2
|
|
fi
|
|
export GIT_REVISION
|
|
|
|
# A local build always writes the local tag, even when .env pins PED_AI_IMAGE to
|
|
# a deployed registry image — otherwise building here would quietly overwrite
|
|
# the tag a deploy is pinned to.
|
|
PED_AI_IMAGE=ped-ai-local:latest
|
|
export PED_AI_IMAGE
|
|
|
|
docker compose build "$@" pediatric-scribe
|
|
|
|
if [ "$GIT_REVISION" != unknown ]; then
|
|
docker tag ped-ai-local:latest "ped-ai-local:$GIT_REVISION"
|
|
echo "Built ped-ai-local:$GIT_REVISION (also tagged :latest)" >&2
|
|
else
|
|
echo 'Built ped-ai-local:latest with no recorded revision' >&2
|
|
fi
|
|
|
|
# Building is not deploying. `docker compose up` takes its image from
|
|
# PED_AI_IMAGE in .env, which this script does not move, so a pin left behind by
|
|
# an earlier deploy starts that older image while every signal reports success:
|
|
# the build completes, `up` says the container started, and /api/health returns
|
|
# {ok:true} from the wrong revision.
|
|
#
|
|
# scripts/deploy.sh is the answer to this and has been since it landed: it moves
|
|
# the pin, waits for health, then asks /api/build which revision is actually
|
|
# serving and rolls back if it is not the one requested. Running `up` by hand
|
|
# skips all three. This points at it rather than repeating half of it.
|
|
if [ "$GIT_REVISION" != unknown ] && [ -f .env ]; then
|
|
PINNED=$(sed -n 's/^PED_AI_IMAGE=//p' .env | tail -1)
|
|
case "$PINNED" in
|
|
'') ;;
|
|
*"$GIT_REVISION") ;;
|
|
*)
|
|
echo >&2
|
|
echo "NOTE: .env still pins PED_AI_IMAGE=$PINNED" >&2
|
|
echo " so 'docker compose up' would start that image, not this build." >&2
|
|
echo >&2
|
|
echo " Deploy this build with:" >&2
|
|
echo " scripts/deploy.sh ped-ai-local:$GIT_REVISION $GIT_REVISION" >&2
|
|
echo >&2
|
|
echo " which moves the pin and then verifies /api/build, rolling back" >&2
|
|
echo " if the container comes up on a different revision." >&2
|
|
echo >&2
|
|
;;
|
|
esac
|
|
fi
|