Building static binaries for monit using alpine linux on docker
#obsolete see compiling-static-binaries instead.
Create a local build folder and mount it inside the alpine linux container
mkdir /tmp/build
docker run --rm -ti -v /tmp/build:/build alpine:3 shInstall build dependency packages in alpine, download the latest monit release from https://mmonit.com/monit/dist/ and build it.
apk add build-base openssl-dev openssl-libs-static autoconf zlib-dev zlib-static bison flex ncurses
cd /build
wget https://mmonit.com/monit/dist/monit-5.28.0.tar.gz
tar xf monit-5.28.0.tar.gz
cd monit-5.28.0
export CLAGS='-static'
export LDFLAGS='-static'
autoreconf -i
./configure --without-pam
make
# In the final linking step gcc ignores $LDFLAGS and does not build static binary
# Manually include '-static' in the final linking command and run it again
strip monit
# Static monit binary is now in ./monit