This repo is an example of how to create a statically linked binary
that can make HTTPS requests. It uses an alpine
docker image to
build a static version of Lua-cURLv3, then creates a
statically linked library out of the resulting file
(src/Lua-cURLv3/lcurl.a
) as well as the following static libraries
which it requires:
/lib/libz.a
fromzlib-static
/usr/lib/libbrotlicommon.a
frombrotli-static
/usr/lib/libbrotlidec.a
frombrotli-static
/usr/lib/libbrotlienc.a
frombrotli-static
/usr/lib/libcrypto.a
fromopenssl-libs-static
/usr/lib/libssl.a
fromopenssl-libs-static
/usr/lib/libnghttp2.a
fromnghttp2-static
/usr/lib/libcurl.a
fromcurl-static
See src/create-lcurl-linked.sh
for the script that creates the
static archive containing all the necessary libraries. This is then
included in the binary by passing --native-module Lua-cURLv3/lcurl-linked.a
to fennel --compile-binary
git
make
docker
To build the static binary, run make fennel-static-http
in the root
of this repo. (This is also the default make target, so just running
make
on its own will have the same effect.)
To get a gzipped version of the binary, run make fennel-static-http.gz
.
All the following numbers are based on the results I got on my
machine. These sizes will be output to the sizes
directory each time
the relevant make targets are built.
- Before running
strip
, the binary is 17M. (seesizes/initial.txt
) - After running
strip
, it shrinks to 3.3M. (seesizes/stripped.txt
) - After gzipping, it shrinks to 1.7M. (see
sizes/gzipped.txt
)