Build containers for multiple Linux distros and archs

I needed a convenient way to test my configure and Makefile improvements on other Linux distros and CPU archs. The effort started with a shell script that detects distro and package manager, then installs all build dependencies like compiler and header files. Since I wanted to verify the correctness of the commands, I created a GitHub Actions workflow that runs the install script and Python’s configure && make in containers of a dozen Linux versions and macOS. To test some CPU architecture specific config options, I also need a way to run tests on ARM, PPC, and big endian s390x, so I added multi-arch support. Once I had the setup in place, another idea pop into my head. How about publishing the test containers to a public registry?

Long story short, I present tiran/cpython_builddep and cpythonbuild containers. It provides build automation for half a dozen CPU archs and more than a dozen Linux distro versions. It works on all platforms that have qemu-user-static, binfmt Kernel module, and either Docker or podman. The images come with all build dependencies and an entry point that automates out-of-tree builds, configure with config.cache, and parallel make. Most images come with ccache support, too. Emulated archs are very slow. I estimate that they are about 7 to 10 times slower than native.

$ podman run --platform linux/s390x --rm -ti -v.:/cpython:Z quay.io/tiran/cpythonbuild:fedora-35
Trying to pull quay.io/tiran/cpythonbuild:fedora-35...
Getting image source signatures
Copying blob 4ff0313afc06 skipped: already exists  
Copying blob e5a4e7eb66cd done  
Copying blob 70da3a733c01 done  
Copying blob 241da2105d2e done  
Copying config 83a334b73c done  
Writing manifest to image destination
Storing signatures
PATH=/usr/lib64/ccache:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
MAKEFLAGS=-j8
configure: loading cache config.cache
checking for git... (cached) found
checking build system type... (cached) s390x-ibm-linux-gnu
checking host system type... (cached) s390x-ibm-linux-gnu
...

$ file builddep/fedora-35-s390x/python
builddep/fedora-35-s390x/python: ELF 64-bit MSB executable, IBM S/390, version 1 (SYSV), dynamically linked, interpreter /lib/ld64.so.1, BuildID[sha1]=6adac0169272edd613263ec2c9acbae854c19bf7, for GNU/Linux 3.2.0, with debug_info, not stripped

containers

* quay.io/tiran/cpythonbuild:alpine-3.12 (linux/amd64, linux/arm64, linux/s390x)
* quay.io/tiran/cpythonbuild:alpine-3.13 (linux/amd64, linux/arm64, linux/s390x)
* quay.io/tiran/cpythonbuild:archlinux (linux/amd64)
* quay.io/tiran/cpythonbuild:centos-7 (linux/amd64, linux/arm64)
* quay.io/tiran/cpythonbuild:centos-8 (linux/amd64, linux/arm64, linux/ppc64le)
* quay.io/tiran/cpythonbuild:debian-buster (linux/amd64, linux/arm64, linux/s390x, linux/386)
* quay.io/tiran/cpythonbuild:debian-bullseye (linux/amd64, linux/arm64, linux/s390x, linux/mips64le)
* quay.io/tiran/cpythonbuild:debian-testing (linux/amd64, linux/arm64, linux/s390x)
* quay.io/tiran/cpythonbuild:fedora-33 (linux/amd64, linux/s390x)
* quay.io/tiran/cpythonbuild:fedora-34 (linux/amd64, linux/s390x)
* quay.io/tiran/cpythonbuild:fedora-35 (linux/amd64, linux/s390x, linux/ppc64le)
* quay.io/tiran/cpythonbuild:ubuntu-bionic (linux/amd64, linux/arm64, linux/s390x)
* quay.io/tiran/cpythonbuild:ubuntu-focal (linux/amd64, linux/arm64, linux/s390x)
* quay.io/tiran/cpythonbuild:ubuntu-hirsute (linux/amd64, linux/arm64, linux/s390x)
* quay.io/tiran/cpythonbuild:ubuntu-impish (linux/amd64, linux/arm64, linux/s390x)
5 Likes