|
| 1 | +# Use an official Ubuntu image as the base. |
| 2 | +FROM ubuntu:jammy as base |
| 3 | + |
| 4 | +ARG DEBIAN_FRONTEND=noninteractive |
| 5 | + |
| 6 | +# Install build tools. |
| 7 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 8 | + apt-transport-https \ |
| 9 | + ca-certificates \ |
| 10 | + ccache \ |
| 11 | + curl \ |
| 12 | + dumb-init \ |
| 13 | + git \ |
| 14 | + gpg \ |
| 15 | + lsb-release \ |
| 16 | + ninja-build \ |
| 17 | + python-is-python3 \ |
| 18 | + python3 \ |
| 19 | + python3-pip \ |
| 20 | + python3-psutil \ |
| 21 | + software-properties-common \ |
| 22 | + unzip \ |
| 23 | + # Clean apt cache to reduce image size. |
| 24 | + && rm -rf /var/lib/apt/lists/* |
| 25 | + |
| 26 | +ENTRYPOINT ["/usr/bin/dumb-init", "--"] |
| 27 | + |
| 28 | +# Install latest CMake release. |
| 29 | +RUN curl -fsSL https://apt.kitware.com/keys/kitware-archive-latest.asc | \ |
| 30 | + gpg --dearmor -o /usr/share/keyrings/kitware-archive-keyring.gpg && \ |
| 31 | + echo "deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ jammy main" | \ |
| 32 | + tee /etc/apt/sources.list.d/kitware.list && \ |
| 33 | + apt-get update && apt-get install -y --no-install-recommends cmake && \ |
| 34 | + rm -rf /var/lib/apt/lists/* |
| 35 | + |
| 36 | +ARG LLVM_VERSION=17 |
| 37 | + |
| 38 | +# Install latest LLVM release. |
| 39 | +RUN curl -fsSL https://apt.llvm.org/llvm-snapshot.gpg.key | \ |
| 40 | + gpg --dearmor -o /usr/share/keyrings/llvm-archive-keyring.gpg && \ |
| 41 | + echo "deb [signed-by=/usr/share/keyrings/llvm-archive-keyring.gpg] http://apt.llvm.org/jammy/ llvm-toolchain-jammy-${LLVM_VERSION} main" | \ |
| 42 | + tee /etc/apt/sources.list.d/llvm.list && \ |
| 43 | + apt-get update && apt-get install -y --no-install-recommends clang-${LLVM_VERSION} lld-${LLVM_VERSION} && \ |
| 44 | + rm -rf /var/lib/apt/lists/* |
| 45 | + |
| 46 | +# Configure default versions of LLVM tools. |
| 47 | +RUN update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${LLVM_VERSION} 100 ;\ |
| 48 | + update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-${LLVM_VERSION} 100 ;\ |
| 49 | + update-alternatives --install /usr/bin/ld.lld ld.lld /usr/bin/ld.lld-${LLVM_VERSION} 100 |
| 50 | + |
| 51 | +# Configure LLVM tools. |
| 52 | +ENV CC=clang |
| 53 | +ENV CXX=clang++ |
| 54 | +ENV LD=ld.lld |
| 55 | + |
| 56 | +# Workaround permissions issues when writing to named volumes. |
| 57 | +# https://github.com/docker/compose/issues/3270#issuecomment-206214034 |
| 58 | +RUN mkdir -p /vol/ccache && chmod -R 1777 /vol |
| 59 | + |
| 60 | +# Volume to store ccache. |
| 61 | +VOLUME /vol/ccache |
| 62 | +ENV CCACHE_DIR=/vol/ccache |
| 63 | + |
| 64 | +# Install CIPD. |
| 65 | +ARG CIPD_PLATFORM=linux-amd64 |
| 66 | + |
| 67 | +RUN curl -fsSL -o /usr/local/bin/cipd "https://chrome-infra-packages.appspot.com/client?platform=${CIPD_PLATFORM}&version=latest" && \ |
| 68 | + chmod +x /usr/local/bin/cipd |
| 69 | + |
| 70 | +ARG FUCHSIA_VERSION=14 |
| 71 | + |
| 72 | +# Install Fuchsia SDK. |
| 73 | +RUN cipd install -root /usr/local/fuchsia/sdk fuchsia/sdk/core/${CIPD_PLATFORM} f${FUCHSIA_VERSION} |
| 74 | + |
| 75 | +# Use the base image to build the image for buildbot. |
| 76 | +FROM base as buildbot |
| 77 | + |
| 78 | +ARG BUILDBOT_VERSION=3.9.2 |
| 79 | + |
| 80 | +# Install buildbot. |
| 81 | +RUN pip3 --no-cache-dir install twisted[tls] && \ |
| 82 | + pip3 install buildbot_worker==${BUILDBOT_VERSION} |
| 83 | + |
| 84 | +RUN useradd -d /var/lib/buildbot -r -s /usr/sbin/nologin buildbot |
| 85 | +WORKDIR /var/lib/buildbot |
| 86 | + |
| 87 | +COPY buildbot.tac . |
| 88 | + |
| 89 | +RUN mkdir -p info && \ |
| 90 | + echo "LLVM infra <[email protected]>" > info/admin && \ |
| 91 | + echo "$(lsb_release -d | cut -f 2-)," \ |
| 92 | + "$(clang --version | head -n1)," \ |
| 93 | + "$(ld.lld --version)," \ |
| 94 | + "$(cmake --version | head -n1)," \ |
| 95 | + "ninja version $(ninja --version)" > info/host |
| 96 | + |
| 97 | +RUN chown -R buildbot:buildbot /var/lib/buildbot |
| 98 | +USER buildbot |
| 99 | + |
| 100 | +# By default, start the Buildbot worker. |
| 101 | +CMD ["twistd", "--pidfile=", "-ny", "buildbot.tac"] |
| 102 | + |
| 103 | +# Use the base image to build the image for buildkite. |
| 104 | +FROM base as buildkite |
| 105 | + |
| 106 | +# Install the Buildkite agent. |
| 107 | +RUN curl -fsSL https://keys.openpgp.org/vks/v1/by-fingerprint/32A37959C2FA5C3C99EFBC32A79206696452D198 | \ |
| 108 | + gpg --dearmor -o /usr/share/keyrings/buildkite-agent-archive-keyring.gpg && \ |
| 109 | + echo "deb [signed-by=/usr/share/keyrings/buildkite-agent-archive-keyring.gpg] https://apt.buildkite.com/buildkite-agent stable main" | \ |
| 110 | + tee /etc/apt/sources.list.d/buildkite-agent.list && \ |
| 111 | + apt-get update && apt-get install -y --no-install-recommends buildkite-agent |
| 112 | + |
| 113 | +# Create user account, some tests fail if run as root. |
| 114 | +WORKDIR /var/lib/buildkite-agent |
| 115 | + |
| 116 | +USER buildkite-agent |
| 117 | + |
| 118 | +# By default, start the Buildkite agent (this requires a token). |
| 119 | +CMD ["buildkite-agent", "start"] |
0 commit comments