feat: add build version injection via CI_COMMIT argument

Inject the build version into the binary using the CI_COMMIT 
argument for better traceability of deployments. Update the 
Dockerfile to pass the commit hash to the build process, 
ensuring that each build contains version information tied 
to the specific commit.
This commit is contained in:
2025-06-13 13:26:56 +02:00
parent 2948905005
commit b4447bb15e
+2 -1
View File
@@ -4,6 +4,7 @@ ADD go.* /build
RUN go mod download
FROM modules as build
ARG CI_COMMIT
WORKDIR /build
ENV CGO_ENABLED=0
ADD . /build
@@ -17,7 +18,7 @@ RUN GOOS=linux GOARCH=amd64 go build \
-a -installsuffix cgo \
-mod=readonly \
-o /release/service \
-ldflags '-w -s' \
-ldflags "-w -s -X main.buildVersion=${CI_COMMIT}" \
./cmd/service/service.go
FROM scratch as export