Skip to content

Commit ac40f61

Browse files
authored
Dockerfile for Fuchsia builders (#82)
This Dockerfile is used to build a Docker image that's used on all Fuchsia builders. Our infrastructure will automatically pick up any changes to this Dockerfile, rebuild and redeploy the image.
1 parent 3b633e8 commit ac40f61

File tree

2 files changed

+161
-0
lines changed

2 files changed

+161
-0
lines changed

buildbot/fuchsia/Dockerfile

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
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"]

buildbot/fuchsia/buildbot.tac

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import fnmatch
2+
import os
3+
import sys
4+
5+
from twisted.application import service
6+
from twisted.python.log import FileLogObserver
7+
from twisted.python.log import ILogObserver
8+
9+
from buildbot_worker.bot import Worker
10+
11+
# setup worker
12+
basedir = os.environ.get("BUILDBOT_BASEDIR",
13+
os.path.abspath(os.path.dirname(__file__)))
14+
15+
application = service.Application('buildbot-worker')
16+
application.setComponent(ILogObserver, FileLogObserver(sys.stdout).emit)
17+
18+
# and worker on the same process!
19+
buildmaster_host = os.environ.get("BUILDMASTER", 'localhost')
20+
port = int(os.environ.get("BUILDMASTER_PORT", 9989))
21+
workername = os.environ.get("WORKERNAME", 'docker')
22+
passwd = os.environ.get("WORKERPASS")
23+
24+
# delete the password from the environ so that it is not leaked in the log
25+
blacklist = os.environ.get("WORKER_ENVIRONMENT_BLACKLIST", "WORKERPASS").split()
26+
for name in list(os.environ.keys()):
27+
for toremove in blacklist:
28+
if fnmatch.fnmatch(name, toremove):
29+
del os.environ[name]
30+
31+
keepalive = 600
32+
umask = None
33+
maxdelay = 300
34+
allow_shutdown = "signal"
35+
maxretries = 10
36+
delete_leftover_dirs = False
37+
38+
s = Worker(buildmaster_host, port, workername, passwd, basedir,
39+
keepalive, umask=umask, maxdelay=maxdelay,
40+
allow_shutdown=allow_shutdown, maxRetries=maxretries,
41+
delete_leftover_dirs=delete_leftover_dirs)
42+
s.setServiceParent(application)

0 commit comments

Comments
 (0)