Skip to content

Commit 48f4b0c

Browse files
adammwk0da
authored andcommitted
Add GCFLAGS
1 parent c04fb29 commit 48f4b0c

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

@@ -367,12 +370,12 @@ binaries: managers clusterawsadm ## Builds and installs all binaries
367370

368371
.PHONY: clusterawsadm
369372
clusterawsadm: ## 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
374377
docker-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
378381
docker-build-all: $(addprefix docker-build-,$(ALL_ARCH))
@@ -391,7 +394,7 @@ managers: ## Alias for manager-aws-infrastructure
391394

392395
.PHONY: manager-aws-infrastructure
393396
manager-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

0 commit comments

Comments
 (0)