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 \ diff --git a/docker/build_ubuntu-22.04/Dockerfile b/docker/build_ubuntu-22.04/Dockerfile index f61cf6053..78cc643b8 100644 --- a/docker/build_ubuntu-22.04/Dockerfile +++ b/docker/build_ubuntu-22.04/Dockerfile @@ -1,24 +1,48 @@ FROM ubuntu:22.04 -RUN \ - dpkg --add-architecture i386 && \ - apt-get update && \ +ARG TARGET_CONTAINER_BUILD_ARCH + +# Fix for some rootless builders +ENV DEBIAN_FRONTEND=noninteractive + +# 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 \ CXX=/usr/bin/clang++-11 \ - PATH=~/.local/bin:${PATH} + PATH=/home/user/.local/bin:${PATH} COPY docker-entrypoint.sh / CMD /docker-entrypoint.sh diff --git a/docker/run_ubuntu-22.04/Dockerfile b/docker/run_ubuntu-22.04/Dockerfile index 75d55f27f..7ad42a99a 100644 --- a/docker/run_ubuntu-22.04/Dockerfile +++ b/docker/run_ubuntu-22.04/Dockerfile @@ -1,18 +1,33 @@ 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 \ + ca-certificates \ tzdata \ openssl \ - libssl3 \ - libssl-dev \ - && \ + python3 \ + libatomic1 \ + libstdc++6 \ + 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 \ + ;; \ + esac && \ + rm -rf /var/lib/apt/lists/* + USER user WORKDIR /home/user