diff --git a/Dockerfile b/Dockerfile index ad6c6b4b9b..caa255f458 100644 --- a/Dockerfile +++ b/Dockerfile @@ -36,13 +36,13 @@ COPY ./ ./ # Build ARG package=. ARG ARCH -ARG ldflags +ARG ldflags=-s -w -extldflags=-static # Do not force rebuild of up-to-date packages (do not use -a) and use the compiler cache folder RUN --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/go/pkg/mod \ CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} \ - go build -ldflags "${ldflags} -extldflags '-static'" \ + go build -ldflags "${ldflags}" \ -o manager ${package} # Production image diff --git a/Makefile b/Makefile index a4fe820341..1a697aad6c 100644 --- a/Makefile +++ b/Makefile @@ -340,7 +340,16 @@ generate-api-docs-%: $(GEN_CRD_API_REFERENCE_DOCS) FORCE .PHONY: docker-build docker-build: ## Build the docker image for controller-manager - docker build -f Dockerfile --build-arg GO_VERSION=$(GO_VERSION) --build-arg goproxy=$(GOPROXY) --build-arg ARCH=$(ARCH) --build-arg ldflags="$(LDFLAGS)" . -t $(CONTROLLER_IMG_TAG) + docker build -f Dockerfile --build-arg GO_VERSION=$(GO_VERSION) \ + --build-arg goproxy=$(GOPROXY) \ + --build-arg ARCH=$(ARCH) . -t $(CONTROLLER_IMG_TAG) + +.PHONY: docker-build-debug +docker-build-debug: ## Build the docker image for controller-manager with debug info + docker build -f Dockerfile --build-arg GO_VERSION=$(GO_VERSION) \ + --build-arg goproxy=$(GOPROXY) \ + --build-arg ARCH=$(ARCH) \ + --build-arg ldflags="-extldflags=-static" . -t $(CONTROLLER_IMG_TAG) .PHONY: docker-push docker-push: ## Push the docker image