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
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:
@@ -12,8 +12,16 @@ FROM --platform=linux/amd64 mcr.microsoft.com/dotnet/sdk:10.0 AS build
|
||||
WORKDIR /src
|
||||
COPY . .
|
||||
RUN dotnet restore ZB.MOM.WW.OtOpcUa.slnx
|
||||
# Commit stamp (#893). .dockerignore keeps .git/ out of the build context, so SourceLink has no
|
||||
# repository to read and the informational version would be a bare "1.0.0". The compose `build.args`
|
||||
# (fed by docker-dev/compose.sh from the host's `git rev-parse HEAD`, plus "-dirty" for an uncommitted
|
||||
# tree) hand it to the SDK as SourceRevisionId, which yields "1.0.0+<sha>" in
|
||||
# AssemblyInformationalVersion (and so Telemetry's service.version). Left empty, the build still
|
||||
# succeeds as "1.0.0". Declared after restore so a new commit does not bust the restore layer.
|
||||
ARG SOURCE_REVISION=
|
||||
RUN dotnet publish src/Server/ZB.MOM.WW.OtOpcUa.Host/ZB.MOM.WW.OtOpcUa.Host.csproj \
|
||||
-c Release -o /app --no-restore
|
||||
-c Release -o /app --no-restore \
|
||||
${SOURCE_REVISION:+-p:SourceRevisionId=${SOURCE_REVISION}}
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS runtime
|
||||
WORKDIR /app
|
||||
|
||||
Reference in New Issue
Block a user