libx52/docker
nirenjan 8914184613 build: Migrate CI to use distro containers
Previously, the build workflow was restricted to running only on Ubuntu
22.04, Ubuntu 24.04 and macOS, which are the only available native
runners on Github Actions. However, the Ubuntu runner does allow us to
run the build inside a container. Therefore, this commit adds the
ability to pull a prebuilt container with all the necessary dependencies
and build libx52 inside of that container. This commit also adds support
scripts to build the containers and run the CI build against those
prebuilt containers locally for testing, without having to rely
exclusively on Github Actions.

This change also adds support for testing libx52 against Alpine Linux,
in order to verify the portability, given that Alpine uses musl instead
of glibc. The limitation is that we need to mount the `/dev/bus/usb`
device tree inside the container, otherwise libusb inside the Alpine
image fails with LIBUSB_ERROR_OTHER. This is not a concern on the other
distributions, but due to limitations in the Github actions environment,
there is no `/dev/bus/usb` tree to export. For this reason, Alpine is
not a part of the CI build, but is available for testing locally.

Also, because a default bare container would need several minutes of
package installation just to get to a point where we could run
build-and-test.sh, this includes a prebuild workflow which generates the
container images and pushes them to ghcr.io, and the build workflow
pulls from there. There is also logic to ensure that we only keep the
latest image, since there is no value in retaining older images.
2026-03-26 12:23:38 -07:00
..
Dockerfile.archlinux build: Migrate CI to use distro containers 2026-03-26 12:23:38 -07:00
Dockerfile.fedora build: Migrate CI to use distro containers 2026-03-26 12:23:38 -07:00
Dockerfile.ubuntu22 build: Migrate CI to use distro containers 2026-03-26 12:23:38 -07:00
Dockerfile.ubuntu24 build: Migrate CI to use distro containers 2026-03-26 12:23:38 -07:00
Dockerfile.ubuntu26 build: Migrate CI to use distro containers 2026-03-26 12:23:38 -07:00
README.md build: Migrate CI to use distro containers 2026-03-26 12:23:38 -07:00
build-containers.sh build: Migrate CI to use distro containers 2026-03-26 12:23:38 -07:00
build-repo.sh build: Migrate CI to use distro containers 2026-03-26 12:23:38 -07:00
ci-setup.sh build: Migrate CI to use distro containers 2026-03-26 12:23:38 -07:00
dockerfile.alpine build: Migrate CI to use distro containers 2026-03-26 12:23:38 -07:00
install-dependencies-alpine.sh build: Migrate CI to use distro containers 2026-03-26 12:23:38 -07:00
install-dependencies-archlinux.sh build: Migrate CI to use distro containers 2026-03-26 12:23:38 -07:00
install-dependencies-fedora.sh build: Migrate CI to use distro containers 2026-03-26 12:23:38 -07:00
install-dependencies-ubuntu.sh build: Migrate CI to use distro containers 2026-03-26 12:23:38 -07:00

README.md

Dockerfiles for CI builds

This repo contains a number of Dockerfiles for building libx52 against multiple distros. Github only supports Ubuntu LTS for it's Linux runners, but libx52 users run multiple distros, including Arch Linux, Gentoo and Fedora.

For this reason, it's better to get a prebuilt Docker image that builds the CI environment, pulling in all the relevant dependencies, and staging the CI build environment as a container within Github. The regular build pipeline can then run on these containers, and this will help ensure that the breakages are reduced to a minimum.

Build Instructions

In order to run the CI build on all the supported platforms, first run the build-containers.sh script, it will find the Dockerfiles for all the suppported platforms in the docker directory, and build the container images for them with the necessary dependencies included.

Once the container images are built, you can build against one or all of the container images by running build-repo.sh. If you don't specify the container distro, which is basically the same as the extension after Dockerfile., it will run everything. If you specify a distro that doesn't exist, or has not been built, the script will silently exit.

Extending to a new distro

To extend the builds to a new distro, create a Dockerfile.<distro> with the necessary instructions to build a container image for that distro. Make sure you install the necessary dependencies for the distro. It is strongly recommended to add a install-dependencies-<distro>.sh so that you can build against multiple versions of that distro, eg. Ubuntu 22.04 and Ubuntu 24.04. Make sure you copy ci-setup.sh to allow setting up the environment, since it is highly likely that the meson dist command will fail if you do not run that script.