From e759cd3517a43d8c55904f5d0fe38aba8f240dbe Mon Sep 17 00:00:00 2001 From: wg1337 <62715122+wg1337@users.noreply.github.com> Date: Sun, 13 Sep 2026 11:01:34 +0300 Subject: [PATCH 1/6] Add multi-arch build support using containers 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. --- docker/build_ubuntu-22.04/Dockerfile | 37 ++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/docker/build_ubuntu-22.04/Dockerfile b/docker/build_ubuntu-22.04/Dockerfile index f61cf6053..23490308f 100644 --- a/docker/build_ubuntu-22.04/Dockerfile +++ b/docker/build_ubuntu-22.04/Dockerfile @@ -1,19 +1,40 @@ FROM ubuntu:22.04 -RUN \ - dpkg --add-architecture i386 && \ - apt-get update && \ +ARG TARGET_CONTAINER_BUILD_ARCH + +# Base layer +RUN apt-get update && \ apt-get install -y \ cmake \ ninja-build \ clang-11 \ - python3-pip \ - gcc-9-multilib \ - g++-9-multilib \ - libstdc++-11-dev:i386 \ - && \ + python3-pip && \ + rm -rf /var/lib/apt/lists/* && \ useradd -m user && \ su user -c 'pip3 install --user conan' +# Arch-specific layer +RUN case "$TARGET_CONTAINER_BUILD_ARCH" in \ + x86_64|x86) \ + dpkg --add-architecture i386 && \ + apt-get update && \ + apt-get install -y \ + gcc-9-multilib \ + g++-9-multilib \ + libstdc++-11-dev:i386 \ + ;; \ + arm*) \ + apt-get update && \ + apt-get install -y \ + libstdc++6 \ + libc6 \ + ;; \ + *) \ + echo "Unsupported TARGET_CONTAINER_BUILD_ARCH: $TARGET_CONTAINER_BUILD_ARCH" >&2 \ + exit 1 \ + ;; \ + esac && \ + rm -rf /var/lib/apt/lists/* + USER user ENV CC=/usr/bin/clang-11 \ From 901fa2d0f67f10fac81602579a2b81ad0f4ae2b9 Mon Sep 17 00:00:00 2001 From: wg1337 <62715122+wg1337@users.noreply.github.com> Date: Sun, 13 Sep 2026 11:07:50 +0300 Subject: [PATCH 2/6] Pass noninteractive flag and properly expand home path 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. --- docker/build_ubuntu-22.04/Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docker/build_ubuntu-22.04/Dockerfile b/docker/build_ubuntu-22.04/Dockerfile index 23490308f..78cc643b8 100644 --- a/docker/build_ubuntu-22.04/Dockerfile +++ b/docker/build_ubuntu-22.04/Dockerfile @@ -1,6 +1,9 @@ FROM ubuntu:22.04 ARG TARGET_CONTAINER_BUILD_ARCH +# Fix for some rootless builders +ENV DEBIAN_FRONTEND=noninteractive + # Base layer RUN apt-get update && \ apt-get install -y \ @@ -39,7 +42,7 @@ USER user ENV CC=/usr/bin/clang-11 \ CXX=/usr/bin/clang++-11 \ - PATH=~/.local/bin:${PATH} + PATH=/home/user/.local/bin:${PATH} COPY docker-entrypoint.sh / CMD /docker-entrypoint.sh From aeb2e5a668d3723844a38a5e4ab8e9aeab716a12 Mon Sep 17 00:00:00 2001 From: wg1337 <62715122+wg1337@users.noreply.github.com> Date: Sun, 13 Sep 2026 11:14:55 +0300 Subject: [PATCH 3/6] Add support for multi-arch runtime container building 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. --- docker/run_ubuntu-22.04/Dockerfile | 36 ++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/docker/run_ubuntu-22.04/Dockerfile b/docker/run_ubuntu-22.04/Dockerfile index 75d55f27f..cd5d996e8 100644 --- a/docker/run_ubuntu-22.04/Dockerfile +++ b/docker/run_ubuntu-22.04/Dockerfile @@ -1,18 +1,40 @@ FROM ubuntu:22.04 ENV DEBIAN_FRONTEND=noninteractive -RUN \ - dpkg --add-architecture i386 && \ - apt-get update && \ +ARG TARGET_CONTAINER_PLATFORM + +# Base layer +RUN apt-get update && \ apt-get install -y --no-install-recommends \ wget \ - libstdc++6:i386 \ tzdata \ openssl \ - libssl3 \ - libssl-dev \ - && \ + python3 \ + libssl3 && \ + rm -rf /var/lib/apt/lists/* && \ useradd -m user +# Arch-specific layer +RUN case "$TARGET_CONTAINER_PLATFORM" in \ + linux/amd64) \ + dpkg --add-architecture i386 && \ + apt-get update && \ + apt-get install -y --no-install-recommends \ + libstdc++6:i386 \ + libssl3:i386 \ + ;; \ + linux/arm|linux/arm64) \ + apt-get update && \ + apt-get install -y --no-install-recommends \ + libstdc++6 \ + libatomic1 \ + ;; \ + *) \ + echo "Unsupported TARGET_CONTAINER_PLATFORM: $TARGET_CONTAINER_PLATFORM" >&2 \ + exit 1 \ + ;; \ + esac && \ + rm -rf /var/lib/apt/lists/* + USER user WORKDIR /home/user From 6520f70626b9787947d9e94005ae182f58c84efb Mon Sep 17 00:00:00 2001 From: wg1337 <62715122+wg1337@users.noreply.github.com> Date: Sun, 13 Sep 2026 11:23:53 +0300 Subject: [PATCH 4/6] Pass the proper arch buld-args during binary building 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". --- docker/build.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docker/build.sh b/docker/build.sh index 911c0d053..9d6a522a1 100755 --- a/docker/build.sh +++ b/docker/build.sh @@ -25,7 +25,28 @@ && target_build_arch=x86 \ || target_build_arch="$TARGET_BUILD_ARCH" +case "$target_build_arch" in + armv8*) + container_platform="linux/arm64" + ;; + + arm*) # Unknown "arm" are marked as 32-bit platforms + container_platform="linux/arm" + ;; + + x86|x86_64) # Ubuntu images don't have a i386 tag, must run the container with a amd64 tag, let's just not support i386 builders + container_platform="linux/amd64" + ;; + + *) + echo "Unsupported container platform: $target_build_arch" + exit 1 + ;; +esac + docker build \ + --platform "$container_platform" \ + --build-arg "TARGET_CONTAINER_BUILD_ARCH=$target_build_arch" \ -t open.mp/build:ubuntu-${ubuntu_version} \ build_ubuntu-${ubuntu_version}/ \ || exit 1 @@ -41,6 +62,7 @@ done docker run \ --rm \ -t \ + --platform "$container_platform" \ -w /code \ -v $PWD/..:/code \ -v $PWD/build:/code/build \ From b37b15631cc50e8df9328d5ed76a38f83fc750b8 Mon Sep 17 00:00:00 2001 From: wg1337 <62715122+wg1337@users.noreply.github.com> Date: Mon, 14 Sep 2026 18:28:36 +0300 Subject: [PATCH 5/6] Install libatomic, libstdc++6 regardless or arch 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. --- docker/run_ubuntu-22.04/Dockerfile | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/docker/run_ubuntu-22.04/Dockerfile b/docker/run_ubuntu-22.04/Dockerfile index cd5d996e8..b11bc144f 100644 --- a/docker/run_ubuntu-22.04/Dockerfile +++ b/docker/run_ubuntu-22.04/Dockerfile @@ -9,6 +9,8 @@ RUN apt-get update && \ tzdata \ openssl \ python3 \ + libatomic1 \ + libstdc++6 \ libssl3 && \ rm -rf /var/lib/apt/lists/* && \ useradd -m user @@ -22,16 +24,6 @@ RUN case "$TARGET_CONTAINER_PLATFORM" in \ libstdc++6:i386 \ libssl3:i386 \ ;; \ - linux/arm|linux/arm64) \ - apt-get update && \ - apt-get install -y --no-install-recommends \ - libstdc++6 \ - libatomic1 \ - ;; \ - *) \ - echo "Unsupported TARGET_CONTAINER_PLATFORM: $TARGET_CONTAINER_PLATFORM" >&2 \ - exit 1 \ - ;; \ esac && \ rm -rf /var/lib/apt/lists/* From 01e755d51a52e534727cc6edf3f0034706004de2 Mon Sep 17 00:00:00 2001 From: wg1337 <62715122+wg1337@users.noreply.github.com> Date: Wed, 16 Sep 2026 18:37:58 +0300 Subject: [PATCH 6/6] Add ca-certificates to runtime container This is needed for the announce mechanism to work, it may not be included because of "--no-install-recommends". --- docker/run_ubuntu-22.04/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/run_ubuntu-22.04/Dockerfile b/docker/run_ubuntu-22.04/Dockerfile index b11bc144f..7ad42a99a 100644 --- a/docker/run_ubuntu-22.04/Dockerfile +++ b/docker/run_ubuntu-22.04/Dockerfile @@ -6,6 +6,7 @@ ARG TARGET_CONTAINER_PLATFORM RUN apt-get update && \ apt-get install -y --no-install-recommends \ wget \ + ca-certificates \ tzdata \ openssl \ python3 \