ansemjo / static-toolbox

Containerized build scripts to compile various static binaries.
6 stars 1 forks source link
buildkit containerized dockerfiles fdisk git gpg img static-build toolbox

STATIC TOOLBOX

compile release

Dockerfile based build scripts to compile various static binaries of useful tools.

I often found myself in shells where I needed a newer version of a particular tool, which was not available through the package manager .. or the system even lacked a package manager to begin with. In that case it can be helpful to have portable binaries that you can just copy to the target without worrying about library dependencies and be able to use it right away.

The scripts placed in build/ are Dockerfiles that must be built with the builtkit frontend. However, the end result is not a container image but a built binary that is saved in the compiled/ directory, which you can then copy where-ever you like. The fact that everything is built inside a container means that you do not need to provide any specific build environment – besides an installation of Docker.

Using the buildx plugin you can even compile binaries for another platform by starting a multi-platform capable builder instance and adding a --platform argument.

DOWNLOAD

The binaries are compiled in a GitHub workflow regularly. These precompiled binaries and all the downloaded sources that were used can be found in the action artifacts: click on a run and download the corresponding archive form the build artifacts.

REQUIREMENTS

USAGE

Available build targets are given by the Dockerfiles in build/:

The output will be placed in compiled/ in a subdirectory matching your native platform.

Some of the scripts use GPG signatures for which the trusted signing keys are stored in build/*.keys files and are imported before checking the downloaded sources.

OTHER PLATFORMS

First, setup buildx for multi-platform building. Let's assume you already ran docker buildx create --use ... etc. and your currently used build server is multi-platform capable. Then you should be able to use the --platform argument with docker build invocations, too.

The Makefile contains targets for most available platforms. In order to build fdisk for linux/arm64 you'd use the compiled/linux-arm64/fdisk/ target:

make compiled/linux-arm64/fdisk/

I haven't actually tested all combinations yet, because it takes a very long time under emulation. Available target platforms are:

MANUAL BUILDS

If you want to add some other arguments to docker build or want to create your own script, this is the command the gets executed in the example above:

DOCKER_BUILDKIT=1 docker build -f build/fdisk build/
  --target binary -o type=local,dest=compiled/linux-arm64/fdisk/ \
  --platform linux/arm64

ADD YOUR OWN

Add your own build scripts in build/: