19f21d341SLouis Dionne#===----------------------------------------------------------------------===##
29f21d341SLouis Dionne#
39f21d341SLouis Dionne# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
49f21d341SLouis Dionne# See https://llvm.org/LICENSE.txt for license information.
59f21d341SLouis Dionne# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
69f21d341SLouis Dionne#
79f21d341SLouis Dionne#===----------------------------------------------------------------------===##
89f21d341SLouis Dionne
99f21d341SLouis Dionne#
109f21d341SLouis Dionne# This Dockerfile describes the base image used to run the various libc++
119f21d341SLouis Dionne# build bots. By default, the image runs the Buildkite Agent, however one
129f21d341SLouis Dionne# can also just start the image with a shell to debug CI failures.
139f21d341SLouis Dionne#
149f21d341SLouis Dionne# To start a Buildkite Agent, run it as:
154f7f7284SLouis Dionne#   $ docker run --env-file <secrets> -it $(docker build -q libcxx/utils/ci)
169f21d341SLouis Dionne#
179b371f5dSLouis Dionne# The environment variables in `<secrets>` should be the ones necessary
189b371f5dSLouis Dionne# to run a BuildKite agent.
199f21d341SLouis Dionne#
20c5659dd4SLouis Dionne# If you're only looking to run the Docker image locally for debugging a
21c5659dd4SLouis Dionne# build bot, see the `run-buildbot-container` script located in this directory.
229f21d341SLouis Dionne#
23c5659dd4SLouis Dionne# A pre-built version of this image is maintained on DockerHub as ldionne/libcxx-builder.
242159ed81SLouis Dionne# To update the image, rebuild it and push it to ldionne/libcxx-builder (which
252159ed81SLouis Dionne# will obviously only work if you have permission to do so).
262159ed81SLouis Dionne#
273765d284SLouis Dionne#   $ docker build -t ldionne/libcxx-builder libcxx/utils/ci
282159ed81SLouis Dionne#   $ docker push ldionne/libcxx-builder
292159ed81SLouis Dionne#
309f21d341SLouis Dionne
31*a7bd1ab7SMark de WeverFROM ubuntu:jammy
329f21d341SLouis Dionne
33738d981eSLouis Dionne# Make sure apt-get doesn't try to prompt for stuff like our time zone, etc.
34738d981eSLouis DionneENV DEBIAN_FRONTEND=noninteractive
35738d981eSLouis Dionne
36738d981eSLouis DionneRUN apt-get update && apt-get install -y bash curl
379f21d341SLouis Dionne
382159ed81SLouis Dionne# Install various tools used by the build or the test suite
39ce3feebdSLouis DionneRUN apt-get update && apt-get install -y ninja-build python3 python3-sphinx python3-distutils python3-psutil git gdb
402159ed81SLouis Dionne
41da593765SDavid Spickett# Locales for gdb and localization tests
42da593765SDavid SpickettRUN apt-get update && apt-get install -y language-pack-en language-pack-fr \
4311c14bcaSMark de Wever                                         language-pack-ja language-pack-ru \
4411c14bcaSMark de Wever                                         language-pack-zh-hans
45da593765SDavid Spickett# These two are not enabled by default so generate them
46da593765SDavid SpickettRUN printf "fr_CA ISO-8859-1\ncs_CZ ISO-8859-2" >> /etc/locale.gen
47da593765SDavid SpickettRUN mkdir /usr/local/share/i1en/
48da593765SDavid SpickettRUN printf "fr_CA ISO-8859-1\ncs_CZ ISO-8859-2" >> /usr/local/share/i1en/SUPPORTED
49da593765SDavid SpickettRUN locale-gen
50da593765SDavid Spickett
518ea2b951SLouis Dionne# Install Clang <latest>, <latest-1> and ToT, which are the ones we support.
52*a7bd1ab7SMark de Wever# We also install <latest-2> because we need to support the "latest-1" of the
53*a7bd1ab7SMark de Wever# current LLVM release branch, which is effectively the <latest-2> of the
54*a7bd1ab7SMark de Wever# tip-of-trunk LLVM. For example, after branching LLVM 14 but before branching
55*a7bd1ab7SMark de Wever# LLVM 15, we still need to have Clang 12 in this Docker image because the LLVM
56*a7bd1ab7SMark de Wever# 14 release branch CI uses it. The tip-of-trunk CI will never use Clang 12,
57*a7bd1ab7SMark de Wever# though.
58a27304c5SLouis DionneENV LLVM_LATEST_VERSION=14
59738d981eSLouis DionneRUN apt-get update && apt-get install -y lsb-release wget software-properties-common
60b6fb0209SMarek KurdejRUN wget https://apt.llvm.org/llvm.sh -O /tmp/llvm.sh
61*a7bd1ab7SMark de Wever# TODO Use the apt.llvm.org version after branching to LLVM 15
62*a7bd1ab7SMark de WeverRUN apt-get update && apt-get install -y clang-$(($LLVM_LATEST_VERSION - 2))
63*a7bd1ab7SMark de Wever#RUN bash /tmp/llvm.sh $(($LLVM_LATEST_VERSION - 2)) # for CI transitions
648ea2b951SLouis DionneRUN bash /tmp/llvm.sh $(($LLVM_LATEST_VERSION - 1)) # previous release
658ea2b951SLouis DionneRUN bash /tmp/llvm.sh $LLVM_LATEST_VERSION          # latest release
668ea2b951SLouis DionneRUN bash /tmp/llvm.sh $(($LLVM_LATEST_VERSION + 1)) # current ToT
679f21d341SLouis Dionne
6878205fafSLouis Dionne# Make the latest version of Clang the "default" compiler on the system
6978205fafSLouis Dionne# TODO: In the future, all jobs should be using an explicitly-versioned version of Clang instead,
7078205fafSLouis Dionne#       and we can get rid of this entirely.
7178205fafSLouis DionneRUN ln -fs /usr/bin/clang++-$LLVM_LATEST_VERSION /usr/bin/c++ && [ -e $(readlink /usr/bin/c++) ]
7278205fafSLouis DionneRUN ln -fs /usr/bin/clang-$LLVM_LATEST_VERSION /usr/bin/cc && [ -e $(readlink /usr/bin/cc) ]
738ea2b951SLouis Dionne
74b6fb0209SMarek Kurdej# Install clang-format
758ea2b951SLouis DionneRUN apt-get install -y clang-format-$LLVM_LATEST_VERSION
768ea2b951SLouis DionneRUN ln -s /usr/bin/clang-format-$LLVM_LATEST_VERSION /usr/bin/clang-format && [ -e $(readlink /usr/bin/clang-format) ]
778ea2b951SLouis DionneRUN ln -s /usr/bin/git-clang-format-$LLVM_LATEST_VERSION /usr/bin/git-clang-format && [ -e $(readlink /usr/bin/git-clang-format) ]
7846ae3604SLouis Dionne
79c10cbb24SNikolas Klauser# Install clang-tidy
80c10cbb24SNikolas KlauserRUN apt-get install -y clang-tidy-$LLVM_LATEST_VERSION
81c10cbb24SNikolas KlauserRUN ln -s /usr/bin/clang-tidy-$LLVM_LATEST_VERSION /usr/bin/clang-tidy && [ -e $(readlink /usr/bin/clang-tidy) ]
82c10cbb24SNikolas Klauser
83*a7bd1ab7SMark de Wever# Install the most recent GCC, like clang install the previous version as a transition.
84*a7bd1ab7SMark de WeverENV GCC_LATEST_VERSION=12
85*a7bd1ab7SMark de WeverRUN apt-get update && apt install -y gcc-$((GCC_LATEST_VERSION - 1)) g++-$((GCC_LATEST_VERSION - 1))
868ea2b951SLouis DionneRUN apt-get update && apt install -y gcc-$GCC_LATEST_VERSION g++-$GCC_LATEST_VERSION
878ea2b951SLouis Dionne
889f21d341SLouis Dionne# Install a recent CMake
89dc0d4b97SLouis DionneRUN wget https://github.com/Kitware/CMake/releases/download/v3.21.1/cmake-3.21.1-linux-x86_64.sh -O /tmp/install-cmake.sh
909f21d341SLouis DionneRUN bash /tmp/install-cmake.sh --prefix=/usr --exclude-subdir --skip-license
919f21d341SLouis DionneRUN rm /tmp/install-cmake.sh
929f21d341SLouis Dionne
932159ed81SLouis Dionne# Change the user to a non-root user, since some of the libc++ tests
942159ed81SLouis Dionne# (e.g. filesystem) require running as non-root. Also setup passwordless sudo.
95738d981eSLouis DionneRUN apt-get update && apt-get install -y sudo
962159ed81SLouis DionneRUN echo "ALL ALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers
972159ed81SLouis DionneRUN useradd --create-home libcxx-builder
982159ed81SLouis DionneUSER libcxx-builder
992159ed81SLouis DionneWORKDIR /home/libcxx-builder
1009f21d341SLouis Dionne
1012159ed81SLouis Dionne# Install the Buildkite agent and dependencies. This must be done as non-root
1022159ed81SLouis Dionne# for the Buildkite agent to be installed in a path where we can find it.
103c71fbdd8SQuinn PhamRUN bash -c "$(curl -sL https://raw.githubusercontent.com/buildkite/agent/main/install.sh)"
1042159ed81SLouis DionneENV PATH="${PATH}:/home/libcxx-builder/.buildkite-agent/bin"
1050a9afaf7SLouis DionneRUN echo "tags=\"queue=libcxx-builders,arch=$(uname -m),os=linux\"" >> "/home/libcxx-builder/.buildkite-agent/buildkite-agent.cfg"
1069f21d341SLouis Dionne
1079f21d341SLouis Dionne# By default, start the Buildkite agent (this requires a token).
1080a9afaf7SLouis DionneCMD buildkite-agent start
109