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.env -it $(docker build -q .) 16 # 17 # The environment variables in `secrets.env` must be replaced by the actual 18 # tokens for this to work. These should obviously never be checked in. 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 . 28 # $ docker push ldionne/libcxx-builder 29 # 30 31 FROM ubuntu:bionic 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 git gdb 40 RUN apt-get update && apt-get install -y libc6-dev-i386 # Required to cross-compile to 32 bits 41 42 # Install the most recently released LLVM 43 RUN apt-get update && apt-get install -y lsb-release wget software-properties-common 44 RUN wget https://apt.llvm.org/llvm.sh -O /tmp/llvm.sh 45 RUN bash /tmp/llvm.sh 46 RUN LLVM_VERSION=$(find /usr/bin -regex '^.+/clang-[0-9.]+$') && LLVM_VERSION=${LLVM_VERSION#*clang-} && echo "LLVM_VERSION=$LLVM_VERSION" > /tmp/env.sh 47 RUN ln -s $(find /usr/bin -regex '^.+/clang\+\+-[0-9.]+$') /usr/bin/clang++ && [ -e $(readlink /usr/bin/clang++) ] 48 RUN ln -s $(find /usr/bin -regex '^.+/clang-[0-9.]+$') /usr/bin/clang && [ -e $(readlink /usr/bin/clang) ] 49 50 # Install the not-yet-released LLVM 51 RUN . /tmp/env.sh && echo "LLVM_TOT_VERSION=$(($LLVM_VERSION + 1))" >> /tmp/env.sh 52 RUN . /tmp/env.sh && bash /tmp/llvm.sh ${LLVM_TOT_VERSION} 53 RUN . /tmp/env.sh && ln -s /usr/bin/clang++-${LLVM_TOT_VERSION} /usr/bin/clang++-tot && [ -e $(readlink /usr/bin/clang++-tot) ] 54 RUN . /tmp/env.sh && ln -s /usr/bin/clang-${LLVM_TOT_VERSION} /usr/bin/clang-tot && [ -e $(readlink /usr/bin/clang-tot) ] 55 56 # Install clang-format 57 RUN . /tmp/env.sh && apt-get install -y clang-format-$LLVM_VERSION 58 RUN ln -s $(find /usr/bin -regex '^.+/clang-format-[0-9.]+$') /usr/bin/clang-format && [ -e $(readlink /usr/bin/clang-format) ] 59 RUN ln -s $(find /usr/bin -regex '^.+/git-clang-format-[0-9.]+$') /usr/bin/git-clang-format && [ -e $(readlink /usr/bin/git-clang-format) ] 60 61 # Install a recent GCC 62 RUN add-apt-repository ppa:ubuntu-toolchain-r/test 63 RUN apt-get update && apt install -y gcc-10 g++-10 64 RUN ln -f -s /usr/bin/g++-10 /usr/bin/g++ && [ -e $(readlink /usr/bin/g++) ] 65 RUN ln -f -s /usr/bin/gcc-10 /usr/bin/gcc && [ -e $(readlink /usr/bin/gcc) ] 66 67 # Install a recent CMake 68 RUN wget https://github.com/Kitware/CMake/releases/download/v3.18.2/cmake-3.18.2-Linux-x86_64.sh -O /tmp/install-cmake.sh 69 RUN bash /tmp/install-cmake.sh --prefix=/usr --exclude-subdir --skip-license 70 RUN rm /tmp/install-cmake.sh 71 72 # Change the user to a non-root user, since some of the libc++ tests 73 # (e.g. filesystem) require running as non-root. Also setup passwordless sudo. 74 RUN apt-get update && apt-get install -y sudo 75 RUN echo "ALL ALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers 76 RUN useradd --create-home libcxx-builder 77 USER libcxx-builder 78 WORKDIR /home/libcxx-builder 79 80 # Install the Buildkite agent and dependencies. This must be done as non-root 81 # for the Buildkite agent to be installed in a path where we can find it. 82 RUN bash -c "$(curl -sL https://raw.githubusercontent.com/buildkite/agent/master/install.sh)" 83 ENV PATH="${PATH}:/home/libcxx-builder/.buildkite-agent/bin" 84 85 # By default, start the Buildkite agent (this requires a token). 86 CMD buildkite-agent start --tags "queue=libcxx-builders" 87