File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed
Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -41,10 +41,11 @@ COPY ./ ./
4141ARG package=.
4242ARG ARCH
4343ARG LDFLAGS
44+ ARG GCFLAGS
4445RUN --mount=type=cache,target=/root/.cache/go-build \
4546 --mount=type=cache,target=/go/pkg/mod \
4647 --mount=type=cache,target=/root/.local/share/golang \
47- CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -ldflags "${LDFLAGS} -extldflags '-static'" -o manager ${package}
48+ CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -gcflags "${GCFLAGS}" - ldflags "${LDFLAGS} -extldflags '-static'" -o manager ${package}
4849ENTRYPOINT [ "/start.sh" , "/workspace/manager" ]
4950
5051# Copy the controller-manager into a thin image
Original file line number Diff line number Diff line change @@ -134,6 +134,9 @@ RBAC_ROOT ?= $(MANIFEST_ROOT)/rbac
134134# Allow overriding the imagePullPolicy
135135PULL_POLICY ?= Always
136136
137+ # Allow overriding the GCFLAGS
138+ GCFLAGS ?=
139+
137140# Set build time variables including version details
138141LDFLAGS := $(shell source ./hack/version.sh; version::ldflags)
139142
@@ -367,12 +370,12 @@ binaries: managers clusterawsadm ## Builds and installs all binaries
367370
368371.PHONY : clusterawsadm
369372clusterawsadm : # # Build clusterawsadm binary
370- go build -ldflags " $( LDFLAGS) " -o $(BIN_DIR ) /clusterawsadm ./cmd/clusterawsadm
373+ go build -gcflags " $( GCFLAGS ) " - ldflags " $( LDFLAGS) " -o $(BIN_DIR ) /clusterawsadm ./cmd/clusterawsadm
371374
372375
373376.PHONY : docker-build
374377docker-build : docker-pull-prerequisites # # Build the docker image for controller-manager
375- docker build --build-arg ARCH=$(ARCH ) --build-arg builder_image=$(GO_CONTAINER_IMAGE ) --build-arg LDFLAGS=" $( LDFLAGS) " . -t $(CORE_CONTROLLER_IMG ) -$(ARCH ) :$(TAG )
378+ docker build --build-arg ARCH=$(ARCH ) --build-arg builder_image=$(GO_CONTAINER_IMAGE ) --build-arg GCFLAGS= " $( GCFLAGS ) " --build-arg LDFLAGS=" $( LDFLAGS) " . -t $(CORE_CONTROLLER_IMG ) -$(ARCH ) :$(TAG )
376379
377380.PHONY : docker-build-all # # Build all the architecture docker images
378381docker-build-all : $(addprefix docker-build-,$(ALL_ARCH ) )
@@ -391,7 +394,7 @@ managers: ## Alias for manager-aws-infrastructure
391394
392395.PHONY : manager-aws-infrastructure
393396manager-aws-infrastructure : # # Build manager binary
394- CGO_ENABLED=0 GOARCH=${ARCH} go build -ldflags " ${LDFLAGS} -extldflags '-static'" -o $(BIN_DIR ) /manager .
397+ CGO_ENABLED=0 GOARCH=${ARCH} go build -gcflags " ${GCFLAGS} " - ldflags " ${LDFLAGS} -extldflags '-static'" -o $(BIN_DIR ) /manager .
395398
396399# #@ test:
397400
You can’t perform that action at this time.
0 commit comments