bitnami / gonit

Drop-in replacement for monit written in Go, with Apache 2.0 license
https://bitnami.com
Apache License 2.0
77 stars 13 forks source link

Static and minimal binary bin? #20

Closed pwFoo closed 2 years ago

pwFoo commented 3 years ago

The binary release isn't static and fails with a custom minimal alpine linux?

        /lib64/ld-linux-x86-64.so.2 (0x7f86d4f11000)
        libpthread.so.0 => /lib64/ld-linux-x86-64.so.2 (0x7f86d4f11000)
        libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7f86d4f11000)

And binary size is big with 8,5MB? Is it possible to build a shrinked and static binary?

juamedgod commented 3 years ago

You could use the below steps to create a custom version of gonit:

$> mkdir build
$> cd build
$> git clone https://github.com/bitnami/gonit.git
$> cd gonit
$> docker run -it -v $(pwd):/go/src/github.com/bitnami/gonit -w /go/src/github.com/bitnami/gonit/ golang:1.14.13-alpine3.11 sh
#> apk add git
#> go get ./...
#> go build -ldflags '-d -s -w' -tags netgo -installsuffix netgo .

That will create the static binary.

If you want to reduce its size, you could try compressing it with upx:

#> apk add upx
#> upx --ultra-brute gonit