| 1 |
#===----------------------------------------------------------------------===## |
| 2 |
# |
| 3 |
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 |
# See https://llvm.org/LICENSE.txt for license information. |
| 5 |
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 |
# |
| 7 |
#===----------------------------------------------------------------------===## |
| 8 |
|
| 9 |
# |
| 10 |
# This Dockerfile describes the base image used to run the various libc++ |
| 11 |
# build bots. By default, the image runs the Buildkite Agent, however one |
| 12 |
# can also just start the image with a shell to debug CI failures. |
| 13 |
# |
| 14 |
# To start a Buildkite Agent, run it as: |
| 15 |
# $ docker run --env-file <secrets> -it $(docker build -q libcxx/utils/ci) |
| 16 |
# |
| 17 |
# The environment variables in `<secrets>` should be the ones necessary |
| 18 |
# to run a BuildKite agent. |
| 19 |
# |
| 20 |
# If you're only looking to run the Docker image locally for debugging a |
| 21 |
# build bot, see the `run-buildbot-container` script located in this directory. |
| 22 |
# |
| 23 |
# A pre-built version of this image is maintained on DockerHub as ldionne/libcxx-builder. |
| 24 |
# To update the image, rebuild it and push it to ldionne/libcxx-builder (which |
| 25 |
# will obviously only work if you have permission to do so). |
| 26 |
# |
| 27 |
# $ docker build -t ldionne/libcxx-builder libcxx/utils/ci |
| 28 |
# $ docker push ldionne/libcxx-builder |
| 29 |
# |
| 30 |
|
| 31 |
FROM ubuntu:jammy |
| 32 |
|
| 33 |
# Make sure apt-get doesn't try to prompt for stuff like our time zone, etc. |
| 34 |
ENV DEBIAN_FRONTEND=noninteractive |
| 35 |
|
| 36 |
RUN apt-get update && apt-get install -y bash curl |
| 37 |
|
| 38 |
# Install various tools used by the build or the test suite |
| 39 |
RUN apt-get update && apt-get install -y ninja-build python3 python3-sphinx python3-distutils python3-psutil git gdb |
| 40 |
|
| 41 |
# Install dependencies required to run the LLDB data formatter tests |
| 42 |
RUN apt-get update && apt-get install -y python3 python3-dev libpython3-dev uuid-dev libncurses5-dev swig3.0 libxml2-dev libedit-dev |
| 43 |
|
| 44 |
# Locales for gdb and localization tests |
| 45 |
RUN apt-get update && apt-get install -y language-pack-en language-pack-fr \ |
| 46 |
language-pack-ja language-pack-ru \ |
| 47 |
language-pack-zh-hans |
| 48 |
# These two are not enabled by default so generate them |
| 49 |
RUN printf "fr_CA ISO-8859-1\ncs_CZ ISO-8859-2" >> /etc/locale.gen |
| 50 |
RUN mkdir /usr/local/share/i1en/ |
| 51 |
RUN printf "fr_CA ISO-8859-1\ncs_CZ ISO-8859-2" >> /usr/local/share/i1en/SUPPORTED |
| 52 |
RUN locale-gen |
| 53 |
|
| 54 |
# Install Clang <latest>, <latest-1> and ToT, which are the ones we support. |
| 55 |
# We also install <latest-2> because we need to support the "latest-1" of the |
| 56 |
# current LLVM release branch, which is effectively the <latest-2> of the |
| 57 |
# tip-of-trunk LLVM. For example, after branching LLVM 14 but before branching |
| 58 |
# LLVM 15, we still need to have Clang 12 in this Docker image because the LLVM |
| 59 |
# 14 release branch CI uses it. The tip-of-trunk CI will never use Clang 12, |
| 60 |
# though. |
| 61 |
ENV LLVM_HEAD_VERSION=16 |
| 62 |
RUN apt-get update && apt-get install -y lsb-release wget software-properties-common |
| 63 |
RUN wget https://apt.llvm.org/llvm.sh -O /tmp/llvm.sh |
| 64 |
RUN bash /tmp/llvm.sh $(($LLVM_HEAD_VERSION - 3)) # for CI transitions |
| 65 |
RUN bash /tmp/llvm.sh $(($LLVM_HEAD_VERSION - 2)) # previous release |
| 66 |
RUN bash /tmp/llvm.sh $(($LLVM_HEAD_VERSION - 1)) # latest release |
| 67 |
RUN bash /tmp/llvm.sh $LLVM_HEAD_VERSION # current ToT |
| 68 |
|
| 69 |
# Make the latest version of Clang the "default" compiler on the system |
| 70 |
# TODO: After branching for LLVM 16, all jobs will be using an |
| 71 |
# explicitly-versioned version of Clang instead, so we can get rid of |
| 72 |
# these symlinks. |
| 73 |
RUN ln -fs /usr/bin/clang++-14 /usr/bin/c++ && [ -e $(readlink /usr/bin/c++) ] |
| 74 |
RUN ln -fs /usr/bin/clang-14 /usr/bin/cc && [ -e $(readlink /usr/bin/cc) ] |
| 75 |
|
| 76 |
# Install clang-format; always use the lastest stable branch. |
| 77 |
# TODO LLVM 16 remove hard-coded version 14 and the symlinks |
| 78 |
RUN apt-get update && apt-get install -y clang-format-$(($LLVM_HEAD_VERSION - 2)) clang-format-$(($LLVM_HEAD_VERSION - 1)) |
| 79 |
RUN ln -s /usr/bin/clang-format-14 /usr/bin/clang-format && [ -e $(readlink /usr/bin/clang-format) ] |
| 80 |
RUN ln -s /usr/bin/git-clang-format-14 /usr/bin/git-clang-format && [ -e $(readlink /usr/bin/git-clang-format) ] |
| 81 |
|
| 82 |
# Install clang-tidy |
| 83 |
# TODO LLVM 16 remove hard-coded version 14 and the symlink |
| 84 |
RUN apt-get update && apt-get install -y clang-tidy-$(($LLVM_HEAD_VERSION - 1)) clang-tidy-$LLVM_HEAD_VERSION clang-tidy-14 |
| 85 |
RUN ln -s /usr/bin/clang-tidy-14 /usr/bin/clang-tidy && [ -e $(readlink /usr/bin/clang-tidy) ] |
| 86 |
|
| 87 |
# Install llvm-dev and libclang-dev to compile custom clang-tidy checks |
| 88 |
RUN apt-get update && apt-get install -y llvm-$(($LLVM_HEAD_VERSION - 1))-dev llvm-$(($LLVM_HEAD_VERSION - 2))-dev \ |
| 89 |
libclang-$(($LLVM_HEAD_VERSION - 1))-dev libclang-$(($LLVM_HEAD_VERSION - 2))-dev |
| 90 |
|
| 91 |
# TODO LLVM16 Don't install llvm-16-dev explicitly |
| 92 |
RUN apt-get update && apt-get install -y llvm-16-dev libclang-16-dev |
| 93 |
|
| 94 |
# Install the most recent GCC, like clang install the previous version as a transition. |
| 95 |
ENV GCC_LATEST_VERSION=12 |
| 96 |
RUN apt-get update && apt install -y gcc-$((GCC_LATEST_VERSION - 1)) g++-$((GCC_LATEST_VERSION - 1)) |
| 97 |
RUN apt-get update && apt install -y gcc-$GCC_LATEST_VERSION g++-$GCC_LATEST_VERSION |
| 98 |
|
| 99 |
# Install a recent CMake |
| 100 |
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 |
| 101 |
RUN bash /tmp/install-cmake.sh --prefix=/usr --exclude-subdir --skip-license |
| 102 |
RUN rm /tmp/install-cmake.sh |
| 103 |
|
| 104 |
# Change the user to a non-root user, since some of the libc++ tests |
| 105 |
# (e.g. filesystem) require running as non-root. Also setup passwordless sudo. |
| 106 |
RUN apt-get update && apt-get install -y sudo |
| 107 |
RUN echo "ALL ALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers |
| 108 |
RUN useradd --create-home libcxx-builder |
| 109 |
USER libcxx-builder |
| 110 |
WORKDIR /home/libcxx-builder |
| 111 |
|
| 112 |
# Install the Buildkite agent and dependencies. This must be done as non-root |
| 113 |
# for the Buildkite agent to be installed in a path where we can find it. |
| 114 |
RUN bash -c "$(curl -sL https://raw.githubusercontent.com/buildkite/agent/main/install.sh)" |
| 115 |
ENV PATH="${PATH}:/home/libcxx-builder/.buildkite-agent/bin" |
| 116 |
RUN echo "tags=\"queue=libcxx-builders,arch=$(uname -m),os=linux\"" >> "/home/libcxx-builder/.buildkite-agent/buildkite-agent.cfg" |
| 117 |
|
| 118 |
# By default, start the Buildkite agent (this requires a token). |
| 119 |
CMD buildkite-agent start |