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
Trying to pull
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
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/, BuildID[sha1]=6adac0169272edd613263ec2c9acbae854c19bf7, for GNU/Linux 3.2.0, with debug_info, not stripped


* (linux/amd64, linux/arm64, linux/s390x)
* (linux/amd64, linux/arm64, linux/s390x)
* (linux/amd64)
* (linux/amd64, linux/arm64)
* (linux/amd64, linux/arm64, linux/ppc64le)
* (linux/amd64, linux/arm64, linux/s390x, linux/386)
* (linux/amd64, linux/arm64, linux/s390x, linux/mips64le)
* (linux/amd64, linux/arm64, linux/s390x)
* (linux/amd64, linux/s390x)
* (linux/amd64, linux/s390x)
* (linux/amd64, linux/s390x, linux/ppc64le)
* (linux/amd64, linux/arm64, linux/s390x)
* (linux/amd64, linux/arm64, linux/s390x)
* (linux/amd64, linux/arm64, linux/s390x)
* (linux/amd64, linux/arm64, linux/s390x)