From f2f22827a6ff3de8d2e782493928433a8304ab2a Mon Sep 17 00:00:00 2001 From: pratikbin <68642400+pratikbin@users.noreply.github.com> Date: Fri, 30 Sep 2022 05:49:52 +0530 Subject: [PATCH] Use `-trimpath` and ldflags `-s -w` build flags (#1880) --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index e02cfa36..dbe90dfa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,14 +30,14 @@ ARG TARGETPLATFORM TARGETOS TARGETARCH TARGETVARIANT VERSION=dev # to avoid https://github.com/moby/buildkit/issues/2334 # We can use docker layer cache so the build is fast enogh anyway # We also use per-platform GOCACHE for the same reason. -env GOCACHE /build/${TARGETPLATFORM}/root/.cache/go-build +ENV GOCACHE /build/${TARGETPLATFORM}/root/.cache/go-build # Build RUN --mount=target=. \ --mount=type=cache,mode=0777,target=${GOCACHE} \ export GOOS=${TARGETOS} GOARCH=${TARGETARCH} GOARM=${TARGETVARIANT#v} && \ - go build -ldflags="-X 'github.com/actions-runner-controller/actions-runner-controller/build.Version=${VERSION}'" -o /out/manager main.go && \ - go build -o /out/github-webhook-server ./cmd/githubwebhookserver + go build -trimpath -ldflags="-s -w -X 'github.com/actions-runner-controller/actions-runner-controller/build.Version=${VERSION}'" -o /out/manager main.go && \ + go build -trimpath -ldflags="-s -w" -o /out/github-webhook-server ./cmd/githubwebhookserver # Use distroless as minimal base image to package the manager binary # Refer to https://github.com/GoogleContainerTools/distroless for more details