The static-linking flag in the Dockerfile build does nothing. With CGO_ENABLED=0 Go links with its internal linker, and -extldflags only goes to an external one. The binary is static because cgo is off, not because of the flag.
Checked in golang:1.26-alpine: go build -ldflags="-v -extldflags=-static" prints no host link line, so no external linker runs. A build without the flag is a statically linked ELF too.
The flag can be dropped, leaving CGO_ENABLED=0 go build -o /cozy-proxy main.go. If a smaller image was the idea, -ldflags="-s -w" would strip the symbol table and DWARF. The current binary still has both (with debug_info, not stripped).
The static-linking flag in the Dockerfile build does nothing. With
CGO_ENABLED=0Go links with its internal linker, and-extldflagsonly goes to an external one. The binary is static because cgo is off, not because of the flag.Checked in
golang:1.26-alpine:go build -ldflags="-v -extldflags=-static"prints nohost linkline, so no external linker runs. A build without the flag is a statically linked ELF too.The flag can be dropped, leaving
CGO_ENABLED=0 go build -o /cozy-proxy main.go. If a smaller image was the idea,-ldflags="-s -w"would strip the symbol table and DWARF. The current binary still has both (with debug_info, not stripped).