1*4d6fc14bSjoerg#===----------------------------------------------------------------------===## 2*4d6fc14bSjoerg# 3*4d6fc14bSjoerg# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*4d6fc14bSjoerg# See https://llvm.org/LICENSE.txt for license information. 5*4d6fc14bSjoerg# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*4d6fc14bSjoerg# 7*4d6fc14bSjoerg#===----------------------------------------------------------------------===## 8*4d6fc14bSjoerg 9*4d6fc14bSjoerg# 10*4d6fc14bSjoerg# This Dockerfile describes the base image used to run the various libc++ 11*4d6fc14bSjoerg# build bots. By default, the image runs the Buildkite Agent, however one 12*4d6fc14bSjoerg# can also just start the image with a shell to debug CI failures. 13*4d6fc14bSjoerg# 14*4d6fc14bSjoerg# To start a Buildkite Agent, run it as: 15*4d6fc14bSjoerg# $ docker run --env-file secrets.env -it $(docker build -q .) 16*4d6fc14bSjoerg# 17*4d6fc14bSjoerg# The environment variables in `secrets.env` must be replaced by the actual 18*4d6fc14bSjoerg# tokens for this to work. These should obviously never be checked in. 19*4d6fc14bSjoerg# 20*4d6fc14bSjoerg# If you're only looking to run the Docker image locally for debugging a 21*4d6fc14bSjoerg# build bot, see the `run-buildbot-container` script located in this directory. 22*4d6fc14bSjoerg# 23*4d6fc14bSjoerg# A pre-built version of this image is maintained on DockerHub as ldionne/libcxx-builder. 24*4d6fc14bSjoerg# To update the image, rebuild it and push it to ldionne/libcxx-builder (which 25*4d6fc14bSjoerg# will obviously only work if you have permission to do so). 26*4d6fc14bSjoerg# 27*4d6fc14bSjoerg# $ docker build -t ldionne/libcxx-builder . 28*4d6fc14bSjoerg# $ docker push ldionne/libcxx-builder 29*4d6fc14bSjoerg# 30*4d6fc14bSjoerg 31*4d6fc14bSjoergFROM ubuntu:bionic 32*4d6fc14bSjoerg 33*4d6fc14bSjoerg# Make sure apt-get doesn't try to prompt for stuff like our time zone, etc. 34*4d6fc14bSjoergENV DEBIAN_FRONTEND=noninteractive 35*4d6fc14bSjoerg 36*4d6fc14bSjoergRUN apt-get update && apt-get install -y bash curl 37*4d6fc14bSjoerg 38*4d6fc14bSjoerg# Install various tools used by the build or the test suite 39*4d6fc14bSjoergRUN apt-get update && apt-get install -y ninja-build python3 python3-sphinx python3-distutils git gdb 40*4d6fc14bSjoergRUN apt-get update && apt-get install -y libc6-dev-i386 # Required to cross-compile to 32 bits 41*4d6fc14bSjoerg 42*4d6fc14bSjoerg# Install the most recently released LLVM 43*4d6fc14bSjoergRUN apt-get update && apt-get install -y lsb-release wget software-properties-common 44*4d6fc14bSjoergRUN wget https://apt.llvm.org/llvm.sh -O /tmp/llvm.sh 45*4d6fc14bSjoergRUN bash /tmp/llvm.sh 46*4d6fc14bSjoergRUN LLVM_VERSION=$(find /usr/bin -regex '^.+/clang-[0-9.]+$') && LLVM_VERSION=${LLVM_VERSION#*clang-} && echo "LLVM_VERSION=$LLVM_VERSION" > /tmp/env.sh 47*4d6fc14bSjoergRUN ln -s $(find /usr/bin -regex '^.+/clang\+\+-[0-9.]+$') /usr/bin/clang++ && [ -e $(readlink /usr/bin/clang++) ] 48*4d6fc14bSjoergRUN ln -s $(find /usr/bin -regex '^.+/clang-[0-9.]+$') /usr/bin/clang && [ -e $(readlink /usr/bin/clang) ] 49*4d6fc14bSjoerg 50*4d6fc14bSjoerg# Install the not-yet-released LLVM 51*4d6fc14bSjoergRUN . /tmp/env.sh && echo "LLVM_TOT_VERSION=$(($LLVM_VERSION + 1))" >> /tmp/env.sh 52*4d6fc14bSjoergRUN . /tmp/env.sh && bash /tmp/llvm.sh ${LLVM_TOT_VERSION} 53*4d6fc14bSjoergRUN . /tmp/env.sh && ln -s /usr/bin/clang++-${LLVM_TOT_VERSION} /usr/bin/clang++-tot && [ -e $(readlink /usr/bin/clang++-tot) ] 54*4d6fc14bSjoergRUN . /tmp/env.sh && ln -s /usr/bin/clang-${LLVM_TOT_VERSION} /usr/bin/clang-tot && [ -e $(readlink /usr/bin/clang-tot) ] 55*4d6fc14bSjoerg 56*4d6fc14bSjoerg# Install clang-format 57*4d6fc14bSjoergRUN . /tmp/env.sh && apt-get install -y clang-format-$LLVM_VERSION 58*4d6fc14bSjoergRUN ln -s $(find /usr/bin -regex '^.+/clang-format-[0-9.]+$') /usr/bin/clang-format && [ -e $(readlink /usr/bin/clang-format) ] 59*4d6fc14bSjoergRUN ln -s $(find /usr/bin -regex '^.+/git-clang-format-[0-9.]+$') /usr/bin/git-clang-format && [ -e $(readlink /usr/bin/git-clang-format) ] 60*4d6fc14bSjoerg 61*4d6fc14bSjoerg# Install a recent GCC 62*4d6fc14bSjoergRUN add-apt-repository ppa:ubuntu-toolchain-r/test 63*4d6fc14bSjoergRUN apt-get update && apt install -y gcc-10 g++-10 64*4d6fc14bSjoergRUN ln -f -s /usr/bin/g++-10 /usr/bin/g++ && [ -e $(readlink /usr/bin/g++) ] 65*4d6fc14bSjoergRUN ln -f -s /usr/bin/gcc-10 /usr/bin/gcc && [ -e $(readlink /usr/bin/gcc) ] 66*4d6fc14bSjoerg 67*4d6fc14bSjoerg# Install a recent CMake 68*4d6fc14bSjoergRUN 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*4d6fc14bSjoergRUN bash /tmp/install-cmake.sh --prefix=/usr --exclude-subdir --skip-license 70*4d6fc14bSjoergRUN rm /tmp/install-cmake.sh 71*4d6fc14bSjoerg 72*4d6fc14bSjoerg# Change the user to a non-root user, since some of the libc++ tests 73*4d6fc14bSjoerg# (e.g. filesystem) require running as non-root. Also setup passwordless sudo. 74*4d6fc14bSjoergRUN apt-get update && apt-get install -y sudo 75*4d6fc14bSjoergRUN echo "ALL ALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers 76*4d6fc14bSjoergRUN useradd --create-home libcxx-builder 77*4d6fc14bSjoergUSER libcxx-builder 78*4d6fc14bSjoergWORKDIR /home/libcxx-builder 79*4d6fc14bSjoerg 80*4d6fc14bSjoerg# Install the Buildkite agent and dependencies. This must be done as non-root 81*4d6fc14bSjoerg# for the Buildkite agent to be installed in a path where we can find it. 82*4d6fc14bSjoergRUN bash -c "$(curl -sL https://raw.githubusercontent.com/buildkite/agent/master/install.sh)" 83*4d6fc14bSjoergENV PATH="${PATH}:/home/libcxx-builder/.buildkite-agent/bin" 84*4d6fc14bSjoerg 85*4d6fc14bSjoerg# By default, start the Buildkite agent (this requires a token). 86*4d6fc14bSjoergCMD buildkite-agent start --tags "queue=libcxx-builders" 87