File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed
Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ COPY hack/ hack/
2020ARG TARGETOS
2121ARG TARGETARCH
2222ARG BUILDPLATFORM
23+ ARG LDFLAGS
2324ENV BUILDARCH=${BUILDPLATFORM##*/}
2425
2526# Install common dependencies
@@ -33,7 +34,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
3334
3435RUN --mount=type=cache,target=/root/.cache/go-build \
3536 --mount=type=cache,target=/go/pkg \
36- CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH GO111MODULE=on go build -ldflags="-s -w " -a -o libvirt-provider ./cmd/libvirt-provider/main.go
37+ CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH GO111MODULE=on go build -ldflags="${LDFLAGS} " -a -o libvirt-provider ./cmd/libvirt-provider/main.go
3738
3839
3940# Install irictl-machine
Original file line number Diff line number Diff line change @@ -10,6 +10,13 @@ MKDOCS_IMG=onmetal/libvirt-provider-docs
1010LIBVIRT_PROVIDER_BIN =$(LOCALBIN ) /libvirt-provider
1111LIBVIRT_PROVIDER_BIN_SOURCE =./cmd/libvirt-provider
1212
13+ # LDFLAGS for the build targets
14+ LDFLAGS ?= -s -w
15+ VERSION =$(shell git describe --tags --abbrev=0)
16+ COMMIT =$(shell git log -n1 --format="% h")
17+ LIBVIRT_VERSION =github.com/ironcore-dev/libvirt-provider/internal/server/version.Version
18+ LIBVIRT_COMMIT =github.com/ironcore-dev/libvirt-provider/internal/server/version.Commit
19+
1320# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
1421ifeq (,$(shell go env GOBIN) )
1522GOBIN =$(shell go env GOPATH) /bin
@@ -123,7 +130,7 @@ run: manifests generate fmt vet ## Run the binary
123130
124131.PHONY : docker-build
125132docker-build : # # Build docker image with partitionlet
126- $(CONTAINER_TOOL ) build $(CONTAINER_BUILDARGS ) -t ${IMG} .
133+ $(CONTAINER_TOOL ) build --build-arg LDFLAGS= " ${LDFLAGS} -X $( LIBVIRT_VERSION ) = $( VERSION ) -X $( LIBVIRT_COMMIT ) = $( COMMIT ) " $(CONTAINER_BUILDARGS ) -t ${IMG} .
127134
128135.PHONY : docker-push
129136docker-push : # # Push docker image with the manager.
You can’t perform that action at this time.
0 commit comments