-
Notifications
You must be signed in to change notification settings - Fork 93
/
Dockerfile
110 lines (96 loc) · 4.09 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#===-- Dockerfile --------------------------------------------------------===//
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
#===----------------------------------------------------------------------===//
# Docker image used for the clangd builder
#
# Environment variables configurable at runtime:
# BUILDBOT_PORT - server port to connect to
#===----------------------------------------------------------------------===//
# Use an official Ubuntu image as the base.
FROM ubuntu:18.04
# Install build tools.
RUN apt-get update && \
apt-get install -y software-properties-common apt-transport-https ca-certificates \
ninja-build git wget gnupg \
# Install ccache for local caching of builds.
ccache \
# Install python for buildbot and LIT.
python3.8 python3-pip python3-psutil && \
# Update system packages
apt-get upgrade -y && \
# Clean apt cache to reduce image size.
apt-get clean
# install latest LLVM release
RUN wget https://apt.llvm.org/llvm.sh && \
chmod +x llvm.sh && \
./llvm.sh 18 && \
rm -rf llvm.sh && \
# clean apt cache to reduce image size
apt-get clean
# Ubuntu ships with old cmake version, install the latest one
# from https://apt.kitware.com/
RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | \
gpg --dearmor - | \
tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null && \
apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main' && \
apt-get update && \
apt-get install -y cmake && \
# Clean apt cache to reduce image size.
apt-get clean
# configure default versions of LLVM tools and python needed for
# buildbot-worker. We deliberately do this after installing all the system
# packages, as apt-get install breaks if we change the Python from default to
# python3.8.
RUN update-alternatives --install /usr/bin/clang clang /usr/bin/clang-18 100 ;\
update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-18 100 ;\
update-alternatives --install /usr/bin/ld.lld ld.lld /usr/bin/lld-18 100 ;\
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 100
# Configure LLVM tools.
ENV CC=clang
ENV CXX=clang++
ENV LD=LLD
# Build and install gRPC for clangd remote index, based on instructions
# https://github.com/llvm/llvm-project/tree/master/clang-tools-extra/clangd/index/remote#building-from-sources
# The grpc version shipped with Ubuntu 18.04 crashes on TSan checks.
ENV GRPC_INSTALL_PATH=/usr/local/lib/grpc
RUN cd /tmp ; \
git clone -b v1.36.3 --depth 1 --recursive --shallow-submodules https://github.com/grpc/grpc && \
cd grpc && mkdir build && cd build && \
cmake -G Ninja -DgRPC_INSTALL=ON -DCMAKE_INSTALL_PREFIX=${GRPC_INSTALL_PATH} -DCMAKE_BUILD_TYPE=Release .. && \
cmake --build . --target install && \
# Clean up sources to reduce image size.
cd / && rm -rf /tmp/grpc
# Install build bot (server was at 2.8.5-dev at time of writing).
RUN pip3 install buildbot-worker==2.8.4
# Workaround permissions issues when writing to named volumes
# https://github.com/docker/compose/issues/3270#issuecomment-206214034
RUN mkdir -p /vol/test /vol/ccache /vol/worker ; \
chmod -R 777 /vol
# Volume to mount secrets into the container.
VOLUME /vol/secrets
# Volume to store data for local, manual testing of the container.
VOLUME /vol/test
# Volume to store ccache.
VOLUME /vol/ccache
ENV CCACHE_DIR=/vol/ccache
# Volume for worker working directory.
VOLUME /vol/worker
# Create user account, some tests fail if run as root.
RUN useradd buildbot --create-home
WORKDIR /vol/worker
# Copy startup script.
COPY run.sh /home/buildbot/
RUN chmod a+rx /home/buildbot/run.sh
USER buildbot
ENV WORKER_NAME="clangd-ubuntu-clang"
# Allow the server port of this agent to be configurable during deployment.
# This way we can connect the same image to production and integration.
# Ports:
# 9990 - production
# 9994 - integration
ENV BUILDBOT_PORT="9994"
# Run startup script.
CMD /home/buildbot/run.sh