From 55e9ba23fd19392657d4878fb2fa5583aa9c6c3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=A1l=20Gy=C3=B6rgy?= Date: Mon, 6 Jul 2026 22:38:51 +0200 Subject: [PATCH] Strip debug info from the release binary (-s -w) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The binary is built and shipped unstripped, so releases carry the full symbol and DWARF tables. Adding -s -w to the existing -ldflags drops the .symtab/.strtab and .debug_* sections and shrinks the amd64 binary by ~29% (locally: 140.1 MB -> 99.8 MB) without touching any functional section: .text, .gopclntab and .rodata are byte-identical, so runtime panic stack traces remain symbolized. The only thing lost is attaching gdb/delve to the shipped binary, which needs DWARF. The -X version injection still works alongside -s -w (verified with --version on the resulting binary). Refs #249 Signed-off-by: Gaál György --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 8d84d7e..61d01df 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,7 +16,7 @@ COPY go.sum . RUN go mod download COPY . . ARG VERSION=unknown -RUN CGO_ENABLED=1 go build -mod=readonly -ldflags "-extldflags='-Wl,-z,lazy' -X 'github.com/coroot/coroot-node-agent/flags.Version=${VERSION}'" -o coroot-node-agent . +RUN CGO_ENABLED=1 go build -mod=readonly -ldflags "-s -w -extldflags='-Wl,-z,lazy' -X 'github.com/coroot/coroot-node-agent/flags.Version=${VERSION}'" -o coroot-node-agent . FROM registry.access.redhat.com/ubi9/ubi