From bb136edd36a1bc08331533f51bbd12da98f5ed9d Mon Sep 17 00:00:00 2001 From: Alexander Shaposhnikov Date: Tue, 31 Mar 2026 15:50:48 -0700 Subject: [PATCH] Refactor Dockerfile.standard and add riscv64 build PiperOrigin-RevId: 892581596 --- .github/workflows/publish-docker.yml | 2 +- docker/Dockerfile.standard | 36 +++++++++++++++++----------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml index fe1c9939d30..f122b3fbd87 100644 --- a/.github/workflows/publish-docker.yml +++ b/.github/workflows/publish-docker.yml @@ -18,7 +18,7 @@ jobs: matrix: include: - image: standard - platforms: linux/amd64,linux/arm64 + platforms: linux/amd64,linux/arm64,linux/riscv64 - image: riscv platforms: linux/amd64 - image: android diff --git a/docker/Dockerfile.standard b/docker/Dockerfile.standard index 79a28e6f1c3..395a850f539 100644 --- a/docker/Dockerfile.standard +++ b/docker/Dockerfile.standard @@ -19,24 +19,32 @@ RUN apt-get install -y \ ccache \ gcc-9 g++-9 \ gcc-13 g++-13 \ - crossbuild-essential-armhf \ - && rm -rf /var/lib/apt/lists/* + clang-18 llvm-18 lld-18 -RUN ln -s /usr/arm-linux-gnueabihf/lib/ld-linux-armhf.so.3 /usr/lib/ld-linux-armhf.so.3 -ENV LD_LIBRARY_PATH=/usr/arm-linux-gnueabihf/lib:${LD_LIBRARY_PATH} +# Declare TARGETARCH once; Buildx populates this automatically +ARG TARGETARCH + +RUN if [ "$TARGETARCH" = "amd64" ] || [ "$TARGETARCH" = "arm64" ]; then \ + apt-get update && \ + apt-get install -y crossbuild-essential-armhf && \ + ln -s /usr/arm-linux-gnueabihf/lib/ld-linux-armhf.so.3 /usr/lib/ld-linux-armhf.so.3 && \ + rm -rf /var/lib/apt/lists/*; \ + else \ + echo "Skipping crossbuild-essential-armhf for architecture: $TARGETARCH"; \ + fi -RUN wget https://apt.llvm.org/llvm.sh && \ - chmod +x llvm.sh && \ - ./llvm.sh 18 && \ - rm llvm.sh +# ENV is not allowed to be conditional in Dockerfile. +ENV LD_LIBRARY_PATH=/usr/arm-linux-gnueabihf/lib:${LD_LIBRARY_PATH} -ARG TARGETARCH -RUN if [ "$TARGETARCH" = "arm64" ]; then \ - wget -O /usr/local/bin/bazel https://github.com/bazelbuild/bazelisk/releases/download/v1.19.0/bazelisk-linux-arm64; \ +RUN if [ "$TARGETARCH" = "amd64" ]; then \ + wget -O /usr/local/bin/bazel https://github.com/bazelbuild/bazelisk/releases/download/v1.19.0/bazelisk-linux-amd64 && \ + chmod +x /usr/local/bin/bazel; \ + elif [ "$TARGETARCH" = "arm64" ]; then \ + wget -O /usr/local/bin/bazel https://github.com/bazelbuild/bazelisk/releases/download/v1.19.0/bazelisk-linux-arm64 && \ + chmod +x /usr/local/bin/bazel; \ else \ - wget -O /usr/local/bin/bazel https://github.com/bazelbuild/bazelisk/releases/download/v1.19.0/bazelisk-linux-amd64; \ - fi && \ - chmod +x /usr/local/bin/bazel + echo "Skipping Bazel installation for unsupported architecture: $TARGETARCH"; \ + fi RUN ln -sf /usr/bin/python3 /usr/bin/python