Closed hh closed 9 years ago
After building serf, run the go build command with the following:
CGO_ENABLED=0 GOOS=linux go build -a -tags netgo -ldflags "-w" -v -o /out/serf
Thanks @kelseyhightower
https://medium.com/@kelseyhightower/optimizing-docker-images-for-static-binaries-b5696e26eb07
Interesting to note that dnsmasq includes libc, so it'll only run on 2.6.26 or later, I wonder how far back a kernel serf will run on?
$ ls -lh dnsmasq serf
-rwxr-xr-x 1 root root 1023K Oct 24 22:49 dnsmasq
-rwxr-xr-x 1 root root 7.9M Oct 24 22:50 serf
$ ldd dnsmasq serf
dnsmasq:
not a dynamic executable
serf:
not a dynamic executable
$ file dnsmasq serf
dnsmasq: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, for GNU/Linux 2.6.26, stripped
serf: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, stripped
Whoops! Sorry @hh I just saw this :smile:
I have a standalone dnsmasq, but serf is linked against libc threading and some others... I'm trying to make a static build of most of my components... to eventually embed in things like hanlon micro-kernel (initrd) etc.
@sethvargo any thoughts on that magic?
And the path to get there: