Skip to content

Commit fe7b9a9

Browse files
committed
Add GCFLAGS
1 parent 904ed61 commit fe7b9a9

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ COPY ./ ./
4141
ARG package=.
4242
ARG ARCH
4343
ARG LDFLAGS
44+
ARG GCFLAGS
4445
RUN --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}
4849
ENTRYPOINT [ "/start.sh", "/workspace/manager" ]
4950

5051
# Copy the controller-manager into a thin image

Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ RBAC_ROOT ?= $(MANIFEST_ROOT)/rbac
134134
# Allow overriding the imagePullPolicy
135135
PULL_POLICY ?= Always
136136

137+
# Allow overriding the GCFLAGS
138+
GCFLAGS ?=
139+
137140
# Set build time variables including version details
138141
LDFLAGS := $(shell source ./hack/version.sh; version::ldflags)
139142

@@ -371,12 +374,12 @@ binaries: managers clusterawsadm ## Builds and installs all binaries
371374

372375
.PHONY: clusterawsadm
373376
clusterawsadm: ## Build clusterawsadm binary
374-
go build -ldflags "$(LDFLAGS)" -o $(BIN_DIR)/clusterawsadm ./cmd/clusterawsadm
377+
go build -gcflags "$(GCFLAGS)" -ldflags "$(LDFLAGS)" -o $(BIN_DIR)/clusterawsadm ./cmd/clusterawsadm
375378

376379

377380
.PHONY: docker-build
378381
docker-build: docker-pull-prerequisites ## Build the docker image for controller-manager
379-
docker build --build-arg ARCH=$(ARCH) --build-arg builder_image=$(GO_CONTAINER_IMAGE) --build-arg LDFLAGS="$(LDFLAGS)" . -t $(CORE_CONTROLLER_IMG)-$(ARCH):$(TAG)
382+
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)
380383

381384
.PHONY: docker-build-all ## Build all the architecture docker images
382385
docker-build-all: $(addprefix docker-build-,$(ALL_ARCH))
@@ -395,7 +398,7 @@ managers: ## Alias for manager-aws-infrastructure
395398

396399
.PHONY: manager-aws-infrastructure
397400
manager-aws-infrastructure: ## Build manager binary
398-
CGO_ENABLED=0 GOARCH=${ARCH} go build -ldflags "${LDFLAGS} -extldflags '-static'" -o $(BIN_DIR)/manager .
401+
CGO_ENABLED=0 GOARCH=${ARCH} go build -gcflags "${GCFLAGS}" -ldflags "${LDFLAGS} -extldflags '-static'" -o $(BIN_DIR)/manager .
399402

400403
##@ test:
401404

0 commit comments

Comments
 (0)