[libcxx-commits] [libcxx] Refactor dockerfile to support Buildkite AND Github Actions (PR #71954)

via libcxx-commits libcxx-commits at lists.llvm.org
Mon Nov 13 13:31:32 PST 2023


================
@@ -65,75 +123,179 @@ RUN locale-gen
 # LLVM 15, we still need to have Clang 12 in this Docker image because the LLVM
 # 14 release branch CI uses it. The tip-of-trunk CI will never use Clang 12,
 # though.
-ARG LLVM_HEAD_VERSION # populated in the docker-compose file
-ENV LLVM_HEAD_VERSION=${LLVM_HEAD_VERSION}
-RUN apt-get update && apt-get install -y lsb-release wget software-properties-common
-RUN wget https://apt.llvm.org/llvm.sh -O /tmp/llvm.sh
-RUN bash /tmp/llvm.sh $(($LLVM_HEAD_VERSION - 3)) # for CI transitions
-RUN bash /tmp/llvm.sh $(($LLVM_HEAD_VERSION - 2)) # previous release
-RUN bash /tmp/llvm.sh $(($LLVM_HEAD_VERSION - 1)) # latest release
-RUN bash /tmp/llvm.sh $LLVM_HEAD_VERSION          # current ToT
-
-# Install clang-scan-deps, which is required to build modules; always all supported versions.
-RUN apt-get update && apt-get install -y clang-tools-$(($LLVM_HEAD_VERSION - 3)) \
-                                         clang-tools-$(($LLVM_HEAD_VERSION - 2)) \
-                                         clang-tools-$(($LLVM_HEAD_VERSION - 1)) \
-                                         clang-tools-$LLVM_HEAD_VERSION
-
-# Install clang-format; always use the lastest stable branch.
-RUN apt-get update && apt-get install -y clang-format-$(($LLVM_HEAD_VERSION - 2)) clang-format-$(($LLVM_HEAD_VERSION - 1))
-
-# Install clang-tidy
-# TODO(LLVM-17) revert D148831 to only install $(($LLVM_HEAD_VERSION - 1)) and $LLVM_HEAD_VERSION
-# The usage of the ToT version is needed due to module issues with Clang 16
-RUN apt-get update && apt-get install -y clang-tidy-$(($LLVM_HEAD_VERSION - 2)) clang-tidy-$(($LLVM_HEAD_VERSION - 1)) clang-tidy-$LLVM_HEAD_VERSION
-
-# Install llvm-dev and libclang-dev to compile custom clang-tidy checks
-# TODO(LLVM-17) revert D148831 to only install $(($LLVM_HEAD_VERSION - 1)) and $LLVM_HEAD_VERSION
-# The usage of the ToT version is needed due to module issues with Clang 16
-RUN apt-get update && apt-get install -y llvm-$(($LLVM_HEAD_VERSION - 2))-dev llvm-$(($LLVM_HEAD_VERSION - 1))-dev     llvm-$LLVM_HEAD_VERSION-dev \
-                                     libclang-$(($LLVM_HEAD_VERSION - 2))-dev libclang-$(($LLVM_HEAD_VERSION - 1))-dev libclang-$LLVM_HEAD_VERSION-dev \
-                                                                                                                       libomp5-$LLVM_HEAD_VERSION
+RUN <<EOF
+  sudo apt-get update
+  wget https://apt.llvm.org/llvm.sh -O /tmp/llvm.sh
+  chmod +x /tmp/llvm.sh
+  sudo /tmp/llvm.sh $(($LLVM_HEAD_VERSION - 3)) all  # for CI transitions
+  sudo /tmp/llvm.sh $(($LLVM_HEAD_VERSION - 2)) all  # previous release
+  sudo /tmp/llvm.sh $(($LLVM_HEAD_VERSION - 1)) all  # latest release
+  sudo /tmp/llvm.sh $LLVM_HEAD_VERSION          all  # current ToT
+  sudo apt-get install -y libomp5-$LLVM_HEAD_VERSION
+  sudo rm -rf /var/lib/apt/lists/*
+EOF
 
 # Install the most recent GCC, like clang install the previous version as a transition.
-RUN add-apt-repository ppa:ubuntu-toolchain-r/test
-ARG GCC_LATEST_VERSION # populated in the docker-compose file
-ENV GCC_LATEST_VERSION=${GCC_LATEST_VERSION}
-RUN apt-get update && apt install -y gcc-$((GCC_LATEST_VERSION - 1)) g++-$((GCC_LATEST_VERSION - 1))
-RUN apt-get update && apt install -y gcc-$GCC_LATEST_VERSION g++-$GCC_LATEST_VERSION
-
-# Remove all, no longer needed, apt data
-RUN rm -rf /var/lib/apt/lists/*
-
-# Install a recent CMake
-RUN wget https://github.com/Kitware/CMake/releases/download/v3.21.1/cmake-3.21.1-linux-x86_64.sh -O /tmp/install-cmake.sh
-RUN bash /tmp/install-cmake.sh --prefix=/usr --exclude-subdir --skip-license
-RUN rm /tmp/install-cmake.sh
-
-# Install a newer CMake for modules
-# TODO Remove the duplicated installation when all runtimes can be build with CMake 3.28.
-RUN wget https://github.com/Kitware/CMake/releases/download/v3.27.1/cmake-3.27.1-linux-x86_64.sh -O /tmp/install-cmake.sh
-RUN bash /tmp/install-cmake.sh --prefix=/opt --exclude-subdir --skip-license
-RUN rm /tmp/install-cmake.sh
-
-RUN wget https://github.com/Kitware/CMake/releases/download/v3.28.0-rc4/cmake-3.28.0-rc4-linux-x86_64.sh -O /tmp/install-cmake.sh
-RUN mkdir /opt/cmake-3.28
-RUN bash /tmp/install-cmake.sh --prefix=/opt/cmake-3.28 --exclude-subdir --skip-license
-RUN rm /tmp/install-cmake.sh
-
-# Change the user to a non-root user, since some of the libc++ tests
-# (e.g. filesystem) require running as non-root. Also setup passwordless sudo.
-RUN apt-get update && apt-get install -y sudo
-RUN echo "ALL ALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers
-RUN useradd --create-home libcxx-builder
+RUN <<EOF
+  sudo add-apt-repository ppa:ubuntu-toolchain-r/test
+  sudo apt-get update
+  sudo apt-get install -y \
+    gcc-$((GCC_LATEST_VERSION - 1)) \
+    g++-$((GCC_LATEST_VERSION - 1))
+    gcc-$GCC_LATEST_VERSION \
+    g++-$GCC_LATEST_VERSION
+  sudo rm -rf /var/lib/apt/lists/*
+EOF
+
+RUN <<EOF
+    # Install a recent CMake
+    wget https://github.com/Kitware/CMake/releases/download/v3.21.1/cmake-3.21.1-linux-x86_64.sh -O /tmp/install-cmake.sh
+    sudo bash /tmp/install-cmake.sh --prefix=/usr --exclude-subdir --skip-license
+    rm /tmp/install-cmake.sh
+
+    # Install a newer CMake for modules
+    # TODO Remove the duplicated installation when all runtimes can be build with CMake 3.28.
+    wget https://github.com/Kitware/CMake/releases/download/v3.27.1/cmake-3.27.1-linux-x86_64.sh -O /tmp/install-cmake.sh
+    sudo bash /tmp/install-cmake.sh --prefix=/opt --exclude-subdir --skip-license
+    rm /tmp/install-cmake.sh
+
+    wget https://github.com/Kitware/CMake/releases/download/v3.28.0-rc4/cmake-3.28.0-rc4-linux-x86_64.sh -O /tmp/install-cmake.sh
+    sudo mkdir /opt/cmake-3.28
+    sudo bash /tmp/install-cmake.sh --prefix=/opt/cmake-3.28 --exclude-subdir --skip-license
+    rm /tmp/install-cmake.sh
+EOF
+
+# Install Docker
----------------
EricWF wrote:

We also need it for the github actions builders. I would rather simply have it in the base image, since you might want it for debugging purposes. Or to allow using this image as the base image, which we can use to _build_ these images from.

https://github.com/llvm/llvm-project/pull/71954


More information about the libcxx-commits mailing list