fix(docker-dev): stamp the git commit into rig image versions via a SOURCE_REVISION build arg (#893)
v2-ci / unit-tests (push) Has been cancelled

.dockerignore keeps .git/ out of the build context, so the in-image publish had
no repository and AssemblyInformationalVersion (Telemetry service.version) was a
bare 1.0.0. The Dockerfile now takes ARG SOURCE_REVISION and passes it to
dotnet publish as SourceRevisionId; docker-compose.yml forwards it as a build arg
for the host and migrator images; the new docker-dev/compose.sh wrapper exports
git rev-parse HEAD (suffixed -dirty for an uncommitted tree; an explicit value
wins) and runs docker compose with the base file. Without the arg the build
still succeeds as 1.0.0. The ARG sits after restore so a new commit does not
bust the restore layer. Mirrors ScadaBridge 7e34d7c2 (ScadaBridge#134).

Claude-Session: https://claude.ai/code/session_01GT67ACmpMR7b9LGRPLijMi
This commit is contained in:
Joseph Doherty
2026-11-12 23:05:31 -05:00
parent 00a5be261c
commit 6147e8dcba
4 changed files with 52 additions and 3 deletions
+3 -1
View File
@@ -87,7 +87,7 @@ The DriverHost actor doesn't spawn drivers from raw DriverInstance rows on its o
```bash
# from the repo root
docker compose -f docker-dev/docker-compose.yml up -d --build
docker-dev/compose.sh up -d --build
# the one-shot migrator + cluster-seed bootstrap the DB; watch the seed finish:
docker compose -f docker-dev/docker-compose.yml logs -f cluster-seed # ^C once it prints "[cluster-seed] done."
@@ -96,6 +96,8 @@ open http://localhost:9200 # Admin UI (Traefik → central-1 or
open http://localhost:8089 # Traefik dashboard
```
`docker-dev/compose.sh` is `docker compose -f docker-dev/docker-compose.yml "$@"` with `SOURCE_REVISION` exported from `git rev-parse HEAD` (suffixed `-dirty` for an uncommitted tree; an explicit `SOURCE_REVISION=...` wins). `.git/` stays out of the build context (`.dockerignore`), so that build arg is the only way the in-image publish learns the commit: with it the Host stamps `1.0.0+<sha>` as its informational version (Telemetry's `service.version`); a plain `docker compose ... --build` still works and stamps a bare `1.0.0` (#893). Check a built image with `docker run --rm --entrypoint sh otopcua-host:dev -c "grep -ao '1\.0\.0[+0-9a-f-]*' OtOpcUa.Host.dll"`.
The first build takes a few minutes (.NET SDK image + restore + publish). **No manual schema step is needed** — on a fresh SQL volume the one-shot `migrator` service applies the EF migrations (the host nodes deliberately don't auto-migrate, since production owns schema changes), then `cluster-seed` populates the cluster/namespace/driver rows. `cluster-seed` and the host nodes wait for the migrator via `service_completed_successfully`, so nothing races an in-progress migration. A plain `docker compose ... up -d` on an existing volume is a fast no-op for both — the named SQL volume keeps the schema + rows across restarts; only `down -v` wipes them, after which the next `up` re-migrates + re-seeds automatically.
## Auth (dev only)