#!/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: 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