Closed haani-niyaz closed 2 years ago
Adding CGO_ENABLED=0 as a sensible default to produce a statically-linked binary.
CGO_ENABLED=0
This setting is also used as the default for the distroless image: https://github.com/GoogleContainerTools/distroless/blob/main/examples/go/Dockerfile
distroless
Further Context
cgo is enabled by default. In the repo Dockerfile, the dynamic linking occurs on golang:1.18 image and runs on gcr.io/distroless/static image where the libraries don't exist. This can cause it to fail.
cgo
golang:1.18
gcr.io/distroless/static
Adding
CGO_ENABLED=0
as a sensible default to produce a statically-linked binary.This setting is also used as the default for the
distroless
image: https://github.com/GoogleContainerTools/distroless/blob/main/examples/go/DockerfileFurther Context
cgo
is enabled by default. In the repo Dockerfile, the dynamic linking occurs ongolang:1.18
image and runs ongcr.io/distroless/static
image where the libraries don't exist. This can cause it to fail.