Louis Dionne | ce55605 | 2020-09-23 09:20:03 -0400 | [diff] [blame] | 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: |
Louis Dionne | f8002ae | 2021-06-21 16:21:39 -0400 | [diff] [blame] | 15 | # $ docker run --env-file <secrets> -it $(docker build -q .) |
Louis Dionne | ce55605 | 2020-09-23 09:20:03 -0400 | [diff] [blame] | 16 | # |
Louis Dionne | f8002ae | 2021-06-21 16:21:39 -0400 | [diff] [blame] | 17 | # The environment variables in `<secrets>` should be the ones necessary |
| 18 | # to run a BuildKite agent. |
Louis Dionne | ce55605 | 2020-09-23 09:20:03 -0400 | [diff] [blame] | 19 | # |
Louis Dionne | 06dbe82 | 2021-03-02 12:59:29 -0500 | [diff] [blame] | 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. |
Louis Dionne | ce55605 | 2020-09-23 09:20:03 -0400 | [diff] [blame] | 22 | # |
Louis Dionne | 06dbe82 | 2021-03-02 12:59:29 -0500 | [diff] [blame] | 23 | # A pre-built version of this image is maintained on DockerHub as ldionne/libcxx-builder. |
Louis Dionne | ef912fe | 2020-09-29 12:48:44 -0400 | [diff] [blame] | 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 | # |
Louis Dionne | 0ae4226 | 2021-09-09 09:59:44 -0400 | [diff] [blame] | 27 | # $ docker build -t ldionne/libcxx-builder libcxx/utils/ci |
Louis Dionne | ef912fe | 2020-09-29 12:48:44 -0400 | [diff] [blame] | 28 | # $ docker push ldionne/libcxx-builder |
| 29 | # |
Louis Dionne | ce55605 | 2020-09-23 09:20:03 -0400 | [diff] [blame] | 30 | |
| 31 | FROM ubuntu:bionic |
| 32 | |
Louis Dionne | 56662a1 | 2020-11-05 15:13:27 -0500 | [diff] [blame] | 33 | # Make sure apt-get doesn't try to prompt for stuff like our time zone, etc. |
| 34 | ENV DEBIAN_FRONTEND=noninteractive |
| 35 | |
Louis Dionne | 0ae4226 | 2021-09-09 09:59:44 -0400 | [diff] [blame] | 36 | # This dummy command is meant to be edited from time to time, which causes the |
| 37 | # CI builders to rebuild their copy of the Docker image. This is not a great |
| 38 | # solution, however without that, the CI builders will keep the same cached |
| 39 | # Docker image forever. |
| 40 | RUN echo 1 |
| 41 | |
Louis Dionne | 56662a1 | 2020-11-05 15:13:27 -0500 | [diff] [blame] | 42 | RUN apt-get update && apt-get install -y bash curl |
Louis Dionne | ce55605 | 2020-09-23 09:20:03 -0400 | [diff] [blame] | 43 | |
Louis Dionne | ef912fe | 2020-09-29 12:48:44 -0400 | [diff] [blame] | 44 | # Install various tools used by the build or the test suite |
Louis Dionne | 5d1db4d | 2020-12-16 17:00:09 -0500 | [diff] [blame] | 45 | RUN apt-get update && apt-get install -y ninja-build python3 python3-sphinx python3-distutils git gdb |
Louis Dionne | 4ed1208 | 2020-12-02 16:35:08 -0500 | [diff] [blame] | 46 | RUN apt-get update && apt-get install -y libc6-dev-i386 # Required to cross-compile to 32 bits |
Louis Dionne | ef912fe | 2020-09-29 12:48:44 -0400 | [diff] [blame] | 47 | |
David Spickett | 2c08c43 | 2021-10-06 16:05:47 +0100 | [diff] [blame] | 48 | # Locales for gdb and localization tests |
| 49 | RUN apt-get update && apt-get install -y language-pack-en language-pack-fr \ |
| 50 | language-pack-ru language-pack-zh-hans |
| 51 | # These two are not enabled by default so generate them |
| 52 | RUN printf "fr_CA ISO-8859-1\ncs_CZ ISO-8859-2" >> /etc/locale.gen |
| 53 | RUN mkdir /usr/local/share/i1en/ |
| 54 | RUN printf "fr_CA ISO-8859-1\ncs_CZ ISO-8859-2" >> /usr/local/share/i1en/SUPPORTED |
| 55 | RUN locale-gen |
| 56 | |
Louis Dionne | 30a2a65 | 2021-07-08 12:19:53 -0400 | [diff] [blame] | 57 | # Install Clang <latest>, <latest-1> and ToT, which are the ones we support. |
| 58 | ENV LLVM_LATEST_VERSION=12 |
Louis Dionne | 56662a1 | 2020-11-05 15:13:27 -0500 | [diff] [blame] | 59 | RUN apt-get update && apt-get install -y lsb-release wget software-properties-common |
Marek Kurdej | d17bd89 | 2021-01-07 12:02:56 +0100 | [diff] [blame] | 60 | RUN wget https://apt.llvm.org/llvm.sh -O /tmp/llvm.sh |
Louis Dionne | 30a2a65 | 2021-07-08 12:19:53 -0400 | [diff] [blame] | 61 | RUN bash /tmp/llvm.sh $(($LLVM_LATEST_VERSION - 1)) # previous release |
| 62 | RUN bash /tmp/llvm.sh $LLVM_LATEST_VERSION # latest release |
| 63 | RUN bash /tmp/llvm.sh $(($LLVM_LATEST_VERSION + 1)) # current ToT |
Louis Dionne | ce55605 | 2020-09-23 09:20:03 -0400 | [diff] [blame] | 64 | |
Louis Dionne | bdb4766 | 2021-07-12 11:10:59 -0400 | [diff] [blame] | 65 | # Make the ToT Clang the "default" compiler on the system |
| 66 | RUN ln -fs /usr/bin/clang++-$(($LLVM_LATEST_VERSION + 1)) /usr/bin/c++ && [ -e $(readlink /usr/bin/c++) ] |
| 67 | RUN ln -fs /usr/bin/clang-$(($LLVM_LATEST_VERSION + 1)) /usr/bin/cc && [ -e $(readlink /usr/bin/cc) ] |
Louis Dionne | 30a2a65 | 2021-07-08 12:19:53 -0400 | [diff] [blame] | 68 | |
Marek Kurdej | d17bd89 | 2021-01-07 12:02:56 +0100 | [diff] [blame] | 69 | # Install clang-format |
Louis Dionne | 30a2a65 | 2021-07-08 12:19:53 -0400 | [diff] [blame] | 70 | RUN apt-get install -y clang-format-$LLVM_LATEST_VERSION |
| 71 | RUN ln -s /usr/bin/clang-format-$LLVM_LATEST_VERSION /usr/bin/clang-format && [ -e $(readlink /usr/bin/clang-format) ] |
| 72 | RUN ln -s /usr/bin/git-clang-format-$LLVM_LATEST_VERSION /usr/bin/git-clang-format && [ -e $(readlink /usr/bin/git-clang-format) ] |
Louis Dionne | 5d1db4d | 2020-12-16 17:00:09 -0500 | [diff] [blame] | 73 | |
Louis Dionne | 30a2a65 | 2021-07-08 12:19:53 -0400 | [diff] [blame] | 74 | # Install the most recent GCC |
| 75 | ENV GCC_LATEST_VERSION=11 |
Louis Dionne | ce55605 | 2020-09-23 09:20:03 -0400 | [diff] [blame] | 76 | RUN add-apt-repository ppa:ubuntu-toolchain-r/test |
Louis Dionne | 30a2a65 | 2021-07-08 12:19:53 -0400 | [diff] [blame] | 77 | RUN apt-get update && apt install -y gcc-$GCC_LATEST_VERSION g++-$GCC_LATEST_VERSION |
| 78 | |
Louis Dionne | ce55605 | 2020-09-23 09:20:03 -0400 | [diff] [blame] | 79 | # Install a recent CMake |
Louis Dionne | 32ccd95 | 2021-08-17 13:35:50 -0400 | [diff] [blame] | 80 | 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 |
Louis Dionne | ce55605 | 2020-09-23 09:20:03 -0400 | [diff] [blame] | 81 | RUN bash /tmp/install-cmake.sh --prefix=/usr --exclude-subdir --skip-license |
| 82 | RUN rm /tmp/install-cmake.sh |
| 83 | |
Louis Dionne | ef912fe | 2020-09-29 12:48:44 -0400 | [diff] [blame] | 84 | # Change the user to a non-root user, since some of the libc++ tests |
| 85 | # (e.g. filesystem) require running as non-root. Also setup passwordless sudo. |
Louis Dionne | 56662a1 | 2020-11-05 15:13:27 -0500 | [diff] [blame] | 86 | RUN apt-get update && apt-get install -y sudo |
Louis Dionne | ef912fe | 2020-09-29 12:48:44 -0400 | [diff] [blame] | 87 | RUN echo "ALL ALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers |
| 88 | RUN useradd --create-home libcxx-builder |
| 89 | USER libcxx-builder |
| 90 | WORKDIR /home/libcxx-builder |
Louis Dionne | ce55605 | 2020-09-23 09:20:03 -0400 | [diff] [blame] | 91 | |
Louis Dionne | ef912fe | 2020-09-29 12:48:44 -0400 | [diff] [blame] | 92 | # Install the Buildkite agent and dependencies. This must be done as non-root |
| 93 | # for the Buildkite agent to be installed in a path where we can find it. |
Louis Dionne | ce55605 | 2020-09-23 09:20:03 -0400 | [diff] [blame] | 94 | RUN bash -c "$(curl -sL https://raw.githubusercontent.com/buildkite/agent/master/install.sh)" |
Louis Dionne | ef912fe | 2020-09-29 12:48:44 -0400 | [diff] [blame] | 95 | ENV PATH="${PATH}:/home/libcxx-builder/.buildkite-agent/bin" |
Louis Dionne | 21240c2 | 2021-07-12 16:01:32 -0400 | [diff] [blame] | 96 | RUN echo "tags=\"queue=libcxx-builders,arch=$(uname -m),os=linux\"" >> "/home/libcxx-builder/.buildkite-agent/buildkite-agent.cfg" |
Louis Dionne | ce55605 | 2020-09-23 09:20:03 -0400 | [diff] [blame] | 97 | |
| 98 | # By default, start the Buildkite agent (this requires a token). |
Louis Dionne | 21240c2 | 2021-07-12 16:01:32 -0400 | [diff] [blame] | 99 | CMD buildkite-agent start |