From dd278b46a8b61a9133b9840e48a46646cef20907 Mon Sep 17 00:00:00 2001 From: Ryan Richard Date: Wed, 5 Aug 2020 17:43:24 -0700 Subject: [PATCH] Build with CGO_ENABLED=0 in Dockerfile - Not strictly necessary at the moment because both our build layer and our run layer are based on alpine, but static linking our binary will help us later when we want to base our run image on something closer to scratch --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3822a57d..6ba1f83a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,8 +33,8 @@ COPY internal ./internal COPY pkg ./pkg COPY tools ./tools COPY hack ./hack -# Build the executable binary -RUN GOOS=linux GOARCH=amd64 go build -ldflags "$(hack/get-ldflags.sh)" -o out ./cmd/placeholder-name-server/... +# Build the executable binary (CGO_ENABLED=0 means static linking) +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "$(hack/get-ldflags.sh)" -o out ./cmd/placeholder-name-server/... FROM alpine:latest # Install CA certs and some tools for debugging