From 3bc94471ca8a90f331366d9593630952b0e7bb10 Mon Sep 17 00:00:00 2001 From: Romain Naour Date: Mon, 10 Feb 2025 21:57:16 +0100 Subject: [PATCH] support/docker: prepare for Aarch64 Docker images With the new 'buildx' command using 'BuildKit' since Docker 23.0 [1], it become easy to build the same image for several architectures [2]. The only requirement is to use a Dockerfile without any architecture specific definition. Since our current Dockefile contains already some i386 specific packages (g++-multilib,libc6:i386) to provide x86 32bits support, we have to install them conditionally. Update the build process described in the Dockerfile accordingly. For now, Aarch64 hosts can't be used by the Buildroot testsuite (yet) since the Bootlin external toolchain (used by default) currently only support x86_64 hosts. [1] https://docs.docker.com/engine/release-notes/23.0/ [2] https://www.docker.com/blog/multi-arch-build-and-images-the-simple-way/ [3] https://www.docker.com/blog/multi-arch-build-what-about-gitlab-ci/ Signed-off-by: Romain Naour Signed-off-by: Peter Korsgaard --- support/docker/Dockerfile | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/support/docker/Dockerfile b/support/docker/Dockerfile index 8b8a478f66..93044eb7fd 100644 --- a/support/docker/Dockerfile +++ b/support/docker/Dockerfile @@ -1,7 +1,9 @@ # This Dockerfile generates the docker image that gets used by Gitlab CI -# To build it (YYYYMMDD.HHMM is the current date and time in UTC): -# docker build -t registry.gitlab.com/buildroot.org/buildroot/base:YYYYMMDD.HHMM support/docker -# docker push registry.gitlab.com/buildroot.org/buildroot/base:YYYYMMDD.HHMM +# To build it for arm64 and amd64 (YYYYMMDD.HHMM is the current date and time in UTC): +# docker buildx create --use +# docker buildx build --platform linux/amd64,linux/arm64/v8 \ +# -t registry.gitlab.com/buildroot.org/buildroot/base:YYYYMMDD.HHMM \ +# --push support/docker # We use a specific tag for the base image *and* the corresponding date # for the repository., so do not forget to update the apt-sources.list @@ -21,9 +23,20 @@ ENV DEBIAN_FRONTEND noninteractive # This repository can be a bit slow at times. Don't panic... COPY apt-sources.list /etc/apt/sources.list +# Install 32bit variant on x86_64 image. +RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \ + dpkg --add-architecture i386; \ +fi + # The container has no package lists, so need to update first -RUN dpkg --add-architecture i386 && \ - apt-get -o APT::Retries=3 update -y +RUN apt-get -o APT::Retries=3 update -y + +RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \ + apt-get -o APT::Retries=3 install -y --no-install-recommends \ + g++-multilib \ + libc6:i386; \ +fi + RUN apt-get -o APT::Retries=3 install -y --no-install-recommends \ bc \ build-essential \ @@ -35,9 +48,8 @@ RUN apt-get -o APT::Retries=3 install -y --no-install-recommends \ cvs \ file \ flake8 \ - g++-multilib \ + g++ \ git \ - libc6:i386 \ libncurses5-dev \ locales \ mercurial \