From b4447bb15e5080cd0f010b07daa7d0399754b6e6 Mon Sep 17 00:00:00 2001 From: Joakim Olsson Date: Fri, 13 Jun 2025 13:26:56 +0200 Subject: [PATCH] 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. --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 16cc76c..ba2f2e1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 -- 2.52.0