From 49308c5c3c2372e4cb7e26f58c1e0dba7953f663 Mon Sep 17 00:00:00 2001 From: Jack Wotherspoon Date: Thu, 23 Feb 2023 12:49:23 -0500 Subject: [PATCH] fix: build statically linked binaries (#1680) --- Dockerfile.alpine | 4 ++-- Dockerfile.bullseye | 2 +- Dockerfile.buster | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile.alpine b/Dockerfile.alpine index 164336e58..fd8c1d337 100644 --- a/Dockerfile.alpine +++ b/Dockerfile.alpine @@ -13,7 +13,7 @@ # limitations under the License. # Use the latest stable golang 1.x to compile to a binary -FROM --platform=$BUILDPLATFORM golang:1 as build +FROM --platform=$BUILDPLATFORM golang:1-alpine as build WORKDIR /go/src/cloud-sql-proxy COPY . . @@ -22,7 +22,7 @@ ARG TARGETOS ARG TARGETARCH RUN go get ./... -RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} \ +RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \ go build -ldflags "-X github.com/GoogleCloudPlatform/cloud-sql-proxy/v2/cmd.metadataString=container.alpine" # Final stage diff --git a/Dockerfile.bullseye b/Dockerfile.bullseye index e12530e59..045329354 100644 --- a/Dockerfile.bullseye +++ b/Dockerfile.bullseye @@ -22,7 +22,7 @@ ARG TARGETOS ARG TARGETARCH RUN go get ./... -RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} \ +RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \ go build -ldflags "-X github.com/GoogleCloudPlatform/cloud-sql-proxy/v2/cmd.metadataString=container.bullseye" # Final stage diff --git a/Dockerfile.buster b/Dockerfile.buster index 14b220dfe..bb8fd600a 100644 --- a/Dockerfile.buster +++ b/Dockerfile.buster @@ -22,7 +22,7 @@ ARG TARGETOS ARG TARGETARCH RUN go get ./... -RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} \ +RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \ go build -ldflags "-X github.com/GoogleCloudPlatform/cloud-sql-proxy/v2/cmd.metadataString=container.buster" # Final stage