Skip to content

Add support for multi-arch container builds - #1271

Open
wg1337 wants to merge 6 commits into
openmultiplayer:masterfrom
wg1337:patch-3
Open

wg1337 wants to merge 6 commits into
openmultiplayer:masterfrom
wg1337:patch-3

Conversation

@wg1337

@wg1337 wg1337 commented Sep 13, 2026

Copy link
Copy Markdown

Currently you can only pass "TARGET_BUILD_ARCH" to specify the omp-server binary files' arch, the script passes this flag to the building container and then conan uses this flag to build the binaries. The problem is that conan does not properly set the profile for the selected arch as a result bulding the binaries can fail.

The solution is simple: use the container runtime's built-in feature to emulate the required arch. This way we can get consistent builds across multiple arches (specifically x86_64 can now build binaries for armv7 and armv8).

As a bonus, the runtime container that runs the binaries can now also be ran with a specific arch.

I did not include the following PR, it is still needed for AMD64 containers:
#1263

Detects the arch from the "TARGET_CONTAINER_BUILD_ARCH" build-arg and only installs the needed packages for the specific arch. Removes apt cache to reduce layer size. Separate "RUN" commands are used to create multiple layers that can be later re-used.
Some builders, specifically rootless podman, can throw a warning due to insufficient access to /dev/pts. This is not critical as it is only a warning, it is still better to pass that flag to avoid those warnings. The "~" symbol is not always properly expanded in Dockerfile, it is better to use the full path.
Uses "TARGET_CONTAINER_PLATFORM" build-arg to determine the arch and only installed requried packages. Removed apt cache to reduce layer size and separated the build into multiple layers that can be reused later.
Forces the container to be emulated to a specific platform, this ensures conan profile has the required arch set properly. This does have a performance penalty since all instructions are emulated. Determines the container platform based on CPU name passed as "TARGET_BUILD_ARCH", only armv8 is recognized as ARM64 (armv8_32 is broken either way), in the future this script may need to manually allow newer ARM CPUs, for now everything unknown is marked as "arm32".
Turns out if you compile a binary for x86_64, then you also need those libraries. To preserve compatibility with i386, it is best to just install i386 related libraries also on 64-bit images too.
This is needed for the announce mechanism to work, it may not be included because of "--no-install-recommends".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant