Compiling Static Binaries With Alpine

A static build is compiled version of a program which has been statically linked against libraries, according to Wikipedia. In practice, it means we can run a binary anywhere in compatible environments without installing dependencies. Although the binary is considerably larger, it greatly simplifies deployments. Learning by Example - cURL First, we take a look at how a static binary of cURL can be produced: 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 # dependencies to build curl apk add build-base clang openssl-dev nghttp2-dev nghttp2-static libssh2-dev libssh2-static # these are missing on at least armhf apk add openssl-libs-static zlib-static || true # gcc is apparantly incapable of building a static binary, even gcc -static helloworld....

published on November 20, 2023 · 3 min · 592 words