176d0caaeSpatrick#===----------------------------------------------------------------------===## 276d0caaeSpatrick# 376d0caaeSpatrick# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 476d0caaeSpatrick# See https://llvm.org/LICENSE.txt for license information. 576d0caaeSpatrick# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 676d0caaeSpatrick# 776d0caaeSpatrick#===----------------------------------------------------------------------===## 876d0caaeSpatrick 976d0caaeSpatrick# 1076d0caaeSpatrick# This Dockerfile describes the base image used to run the various libc++ 1176d0caaeSpatrick# build bots. By default, the image runs the Buildkite Agent, however one 1276d0caaeSpatrick# can also just start the image with a shell to debug CI failures. 1376d0caaeSpatrick# 1476d0caaeSpatrick# To start a Buildkite Agent, run it as: 15*4bdff4beSrobert# $ docker run --env-file <secrets> -it $(docker build -q libcxx/utils/ci) 1676d0caaeSpatrick# 1776d0caaeSpatrick# The environment variables in `<secrets>` should be the ones necessary 1876d0caaeSpatrick# to run a BuildKite agent. 1976d0caaeSpatrick# 2076d0caaeSpatrick# If you're only looking to run the Docker image locally for debugging a 2176d0caaeSpatrick# build bot, see the `run-buildbot-container` script located in this directory. 2276d0caaeSpatrick# 2376d0caaeSpatrick# A pre-built version of this image is maintained on DockerHub as ldionne/libcxx-builder. 2476d0caaeSpatrick# To update the image, rebuild it and push it to ldionne/libcxx-builder (which 2576d0caaeSpatrick# will obviously only work if you have permission to do so). 2676d0caaeSpatrick# 27*4bdff4beSrobert# $ docker build -t ldionne/libcxx-builder libcxx/utils/ci 2876d0caaeSpatrick# $ docker push ldionne/libcxx-builder 2976d0caaeSpatrick# 3076d0caaeSpatrick 31*4bdff4beSrobertFROM ubuntu:jammy 3276d0caaeSpatrick 3376d0caaeSpatrick# Make sure apt-get doesn't try to prompt for stuff like our time zone, etc. 3476d0caaeSpatrickENV DEBIAN_FRONTEND=noninteractive 3576d0caaeSpatrick 3676d0caaeSpatrickRUN apt-get update && apt-get install -y bash curl 3776d0caaeSpatrick 3876d0caaeSpatrick# Install various tools used by the build or the test suite 39*4bdff4beSrobertRUN apt-get update && apt-get install -y ninja-build python3 python3-sphinx python3-distutils python3-psutil git gdb 40*4bdff4beSrobert 41*4bdff4beSrobert# Install dependencies required to run the LLDB data formatter tests 42*4bdff4beSrobertRUN apt-get update && apt-get install -y python3 python3-dev libpython3-dev uuid-dev libncurses5-dev swig3.0 libxml2-dev libedit-dev 43*4bdff4beSrobert 44*4bdff4beSrobert# Locales for gdb and localization tests 45*4bdff4beSrobertRUN apt-get update && apt-get install -y language-pack-en language-pack-fr \ 46*4bdff4beSrobert language-pack-ja language-pack-ru \ 47*4bdff4beSrobert language-pack-zh-hans 48*4bdff4beSrobert# These two are not enabled by default so generate them 49*4bdff4beSrobertRUN printf "fr_CA ISO-8859-1\ncs_CZ ISO-8859-2" >> /etc/locale.gen 50*4bdff4beSrobertRUN mkdir /usr/local/share/i1en/ 51*4bdff4beSrobertRUN printf "fr_CA ISO-8859-1\ncs_CZ ISO-8859-2" >> /usr/local/share/i1en/SUPPORTED 52*4bdff4beSrobertRUN locale-gen 5376d0caaeSpatrick 5476d0caaeSpatrick# Install Clang <latest>, <latest-1> and ToT, which are the ones we support. 55*4bdff4beSrobert# We also install <latest-2> because we need to support the "latest-1" of the 56*4bdff4beSrobert# current LLVM release branch, which is effectively the <latest-2> of the 57*4bdff4beSrobert# tip-of-trunk LLVM. For example, after branching LLVM 14 but before branching 58*4bdff4beSrobert# LLVM 15, we still need to have Clang 12 in this Docker image because the LLVM 59*4bdff4beSrobert# 14 release branch CI uses it. The tip-of-trunk CI will never use Clang 12, 60*4bdff4beSrobert# though. 61*4bdff4beSrobertENV LLVM_HEAD_VERSION=16 6276d0caaeSpatrickRUN apt-get update && apt-get install -y lsb-release wget software-properties-common 6376d0caaeSpatrickRUN wget https://apt.llvm.org/llvm.sh -O /tmp/llvm.sh 64*4bdff4beSrobertRUN bash /tmp/llvm.sh $(($LLVM_HEAD_VERSION - 3)) # for CI transitions 65*4bdff4beSrobertRUN bash /tmp/llvm.sh $(($LLVM_HEAD_VERSION - 2)) # previous release 66*4bdff4beSrobertRUN bash /tmp/llvm.sh $(($LLVM_HEAD_VERSION - 1)) # latest release 67*4bdff4beSrobertRUN bash /tmp/llvm.sh $LLVM_HEAD_VERSION # current ToT 6876d0caaeSpatrick 69*4bdff4beSrobert# Make the latest version of Clang the "default" compiler on the system 70*4bdff4beSrobert# TODO: After branching for LLVM 16, all jobs will be using an 71*4bdff4beSrobert# explicitly-versioned version of Clang instead, so we can get rid of 72*4bdff4beSrobert# these symlinks. 73*4bdff4beSrobertRUN ln -fs /usr/bin/clang++-14 /usr/bin/c++ && [ -e $(readlink /usr/bin/c++) ] 74*4bdff4beSrobertRUN ln -fs /usr/bin/clang-14 /usr/bin/cc && [ -e $(readlink /usr/bin/cc) ] 7576d0caaeSpatrick 76*4bdff4beSrobert# Install clang-format; always use the lastest stable branch. 77*4bdff4beSrobert# TODO LLVM 16 remove hard-coded version 14 and the symlinks 78*4bdff4beSrobertRUN apt-get update && apt-get install -y clang-format-$(($LLVM_HEAD_VERSION - 2)) clang-format-$(($LLVM_HEAD_VERSION - 1)) 79*4bdff4beSrobertRUN ln -s /usr/bin/clang-format-14 /usr/bin/clang-format && [ -e $(readlink /usr/bin/clang-format) ] 80*4bdff4beSrobertRUN ln -s /usr/bin/git-clang-format-14 /usr/bin/git-clang-format && [ -e $(readlink /usr/bin/git-clang-format) ] 8176d0caaeSpatrick 82*4bdff4beSrobert# Install clang-tidy 83*4bdff4beSrobert# TODO LLVM 16 remove hard-coded version 14 and the symlink 84*4bdff4beSrobertRUN apt-get update && apt-get install -y clang-tidy-$(($LLVM_HEAD_VERSION - 1)) clang-tidy-$LLVM_HEAD_VERSION clang-tidy-14 85*4bdff4beSrobertRUN ln -s /usr/bin/clang-tidy-14 /usr/bin/clang-tidy && [ -e $(readlink /usr/bin/clang-tidy) ] 86*4bdff4beSrobert 87*4bdff4beSrobert# Install llvm-dev and libclang-dev to compile custom clang-tidy checks 88*4bdff4beSrobertRUN apt-get update && apt-get install -y llvm-$(($LLVM_HEAD_VERSION - 1))-dev llvm-$(($LLVM_HEAD_VERSION - 2))-dev \ 89*4bdff4beSrobert libclang-$(($LLVM_HEAD_VERSION - 1))-dev libclang-$(($LLVM_HEAD_VERSION - 2))-dev 90*4bdff4beSrobert 91*4bdff4beSrobert# TODO LLVM16 Don't install llvm-16-dev explicitly 92*4bdff4beSrobertRUN apt-get update && apt-get install -y llvm-16-dev libclang-16-dev 93*4bdff4beSrobert 94*4bdff4beSrobert# Install the most recent GCC, like clang install the previous version as a transition. 95*4bdff4beSrobertENV GCC_LATEST_VERSION=12 96*4bdff4beSrobertRUN apt-get update && apt install -y gcc-$((GCC_LATEST_VERSION - 1)) g++-$((GCC_LATEST_VERSION - 1)) 9776d0caaeSpatrickRUN apt-get update && apt install -y gcc-$GCC_LATEST_VERSION g++-$GCC_LATEST_VERSION 9876d0caaeSpatrick 9976d0caaeSpatrick# Install a recent CMake 100*4bdff4beSrobertRUN wget https://github.com/Kitware/CMake/releases/download/v3.21.1/cmake-3.21.1-linux-x86_64.sh -O /tmp/install-cmake.sh 10176d0caaeSpatrickRUN bash /tmp/install-cmake.sh --prefix=/usr --exclude-subdir --skip-license 10276d0caaeSpatrickRUN rm /tmp/install-cmake.sh 10376d0caaeSpatrick 10476d0caaeSpatrick# Change the user to a non-root user, since some of the libc++ tests 10576d0caaeSpatrick# (e.g. filesystem) require running as non-root. Also setup passwordless sudo. 10676d0caaeSpatrickRUN apt-get update && apt-get install -y sudo 10776d0caaeSpatrickRUN echo "ALL ALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers 10876d0caaeSpatrickRUN useradd --create-home libcxx-builder 10976d0caaeSpatrickUSER libcxx-builder 11076d0caaeSpatrickWORKDIR /home/libcxx-builder 11176d0caaeSpatrick 11276d0caaeSpatrick# Install the Buildkite agent and dependencies. This must be done as non-root 11376d0caaeSpatrick# for the Buildkite agent to be installed in a path where we can find it. 114*4bdff4beSrobertRUN bash -c "$(curl -sL https://raw.githubusercontent.com/buildkite/agent/main/install.sh)" 11576d0caaeSpatrickENV PATH="${PATH}:/home/libcxx-builder/.buildkite-agent/bin" 11676d0caaeSpatrickRUN echo "tags=\"queue=libcxx-builders,arch=$(uname -m),os=linux\"" >> "/home/libcxx-builder/.buildkite-agent/buildkite-agent.cfg" 11776d0caaeSpatrick 11876d0caaeSpatrick# By default, start the Buildkite agent (this requires a token). 11976d0caaeSpatrickCMD buildkite-agent start 120