Docker rig image stamps service.version / ProductVersion without the git SHA (.dockerignore excludes .git) #134
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Found during ScadaBridge#133 (2026-11-12). On the docker rig (built by
docker/deploy.shfrommain482ac665), the OTLP Resource carriesservice.version = "1.0.0". A host-built process stamps1.0.0+<git sha>(the scadaproj#55 Site run showed1.0.0+a633005f…).Cause:
.dockerignoreexcludes.git/, so the in-containerdotnet publishhas no repository and noSourceRevisionId. Telemetry 0.3.0 defaultsservice.versionfromAssemblyInformationalVersion, so it falls back to the bare version. The same applies to anything else that reads the informational version on the rig, such as theVersionInfoused to identify a deployed commit.This is rig-only. Wonder deploys are published from a checkout and keep the SHA.
Fix (recommended):
docker/build.shpasses--build-arg SOURCE_REVISION=$(git rev-parse HEAD), and the Dockerfile addsARG SOURCE_REVISION+-p:SourceRevisionId=$SOURCE_REVISIONon the publish. That keeps.gitout of the build context. Verify by rebuilding and checking/healthor the OTLP Resource for+<sha>.Fixed on
mainin7e34d7c2.Change
docker/Dockerfile: the build stage declaresARG SOURCE_REVISION=, placed afterCOPY src/ src/so a new commit doesn't invalidate the restore layer. The publish appends${SOURCE_REVISION:+-p:SourceRevisionId=${SOURCE_REVISION}}, so an empty or missing arg leaves the publish command as it was.docker/build.shsetsSOURCE_REVISIONtogit rev-parse HEAD, adding-dirtywhengit status --porcelain --untracked-files=nois non-empty. You can override it by exportingSOURCE_REVISION. Outside a git checkout it stays empty. The script printsSource revision: …. Bothdocker/deploy.shanddocker-env2/deploy.shgo throughbuild.sh, so both are covered..git/is still in.dockerignore.Verification (image built from the commit; the version is read straight from the assembly's informational-version attribute)
I tested the
build.shrevision snippet on its own: a dirty tree gives<sha>-dirty, and a non-git directory gives<none>.I didn't redeploy the rig. It had been recreated about 20 min earlier, and another agent (#125) was running the full suite at the time. The next
docker/deploy.shfrommainwill stamp1.0.0+<sha>, and you can confirm it in the OTLP Resourceservice.version.Family check
docker-dev/has the same gap: in-container publish,.git/excluded, and the currentotopcua-host:devimage stamps a bare1.0.0. Filed as lmxopcua#893.docker/Dockerfile,Dockerfile.production,f1b-gate) and BTDBdocker/aren't affected. They publish on the host and onlyCOPY publish/, so the SHA comes from the checkout.