Skip to content

Commit a590af8

Browse files
committed
Dockerfile: strip out symbol table by default for public images
Signed-off-by: smoshiur1237 <[email protected]>
1 parent 4380b20 commit a590af8

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ COPY ./ ./
3636
# Build
3737
ARG package=.
3838
ARG ARCH
39-
ARG ldflags
39+
ARG ldflags=-s -w -extldflags=-static
4040

4141
# Do not force rebuild of up-to-date packages (do not use -a) and use the compiler cache folder
4242
RUN --mount=type=cache,target=/root/.cache/go-build \
4343
--mount=type=cache,target=/go/pkg/mod \
4444
CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} \
45-
go build -ldflags "${ldflags} -extldflags '-static'" \
45+
go build -ldflags "${ldflags}" \
4646
-o manager ${package}
4747

4848
# Production image

Makefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,16 @@ generate-api-docs-%: $(GEN_CRD_API_REFERENCE_DOCS) FORCE
340340

341341
.PHONY: docker-build
342342
docker-build: ## Build the docker image for controller-manager
343-
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)
343+
docker build -f Dockerfile --build-arg GO_VERSION=$(GO_VERSION) \
344+
--build-arg goproxy=$(GOPROXY) \
345+
--build-arg ARCH=$(ARCH) . -t $(CONTROLLER_IMG_TAG)
346+
347+
.PHONY: docker-build-debug
348+
docker-build-debug: ## Build the docker image for controller-manager with debug info
349+
docker build -f Dockerfile --build-arg GO_VERSION=$(GO_VERSION) \
350+
--build-arg goproxy=$(GOPROXY) \
351+
--build-arg ARCH=$(ARCH) \
352+
--build-arg ldflags="-extldflags=-static" . -t $(CONTROLLER_IMG_TAG)
344353

345354
.PHONY: docker-push
346355
docker-push: ## Push the docker image

0 commit comments

Comments
 (0)