1
0
Fork 0

config files to run buildkite for Linux

This commit is contained in:
Christian Kühnel 2020-01-17 10:33:08 +01:00
parent 7d2766304e
commit c350bec730
4 changed files with 115 additions and 1 deletions

View file

@ -0,0 +1,57 @@
FROM debian:testing
RUN apt-get update ;\
apt-get install -y --no-install-recommends locales \
cmake ninja-build git ca-certificates clang lld ccache python3 build-essential \
clang-tidy clang-format \
python3-psutil zip wget \
openjdk-11-jdk \
python3-pip python3-setuptools \
swig python3-dev libedit-dev libncurses5-dev libxml2-dev liblzma-dev golang rsync jq; \
apt-get clean
# Make python3 default (needed by git-clang-format and others).
RUN rm -f /usr/bin/python && ln -s /usr/bin/python3 /usr/bin/python
# required for openssh server
RUN mkdir -p /run/sshd
ARG user=buildkite
ARG group=buildkite
ARG uid=1000
ARG gid=1000
ARG AGENT_WORKDIR=/home/${user}/agent
RUN mkdir -p /scripts
COPY start_agent.sh /scripts/
# install python dependencies for the scripts
RUN pip3 install -r https://raw.githubusercontent.com/google/llvm-premerge-checks/master/scripts/phabtalk/requirements.txt
RUN groupadd -g ${gid} ${group} ;\
useradd -c "buildkite user" -d /home/${user} -u ${uid} -g ${gid} -m ${user} ;\
mkdir /home/${user}/ccache
RUN chown -R ${user}:${user} /home/${user}
WORKDIR /home/${user}
ENV CCACHE_PATH=/mnt/disks/ssd0/ccache
# configure locale
RUN sed --in-place '/en_US.UTF-8/s/^#//' /etc/locale.gen ;\
locale-gen
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
# buildkite
RUN apt-get install -y apt-transport-https gnupg;\
sh -c 'echo deb https://apt.buildkite.com/buildkite-agent stable main > /etc/apt/sources.list.d/buildkite-agent.list' ;\
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 32A37959C2FA5C3C99EFBC32A79206696452D198 ;\
apt-get update ;\
apt-get install -y buildkite-agent
VOLUME /credentials
CMD ["/scripts/start_agent.sh"]

View file

@ -0,0 +1,33 @@
#!/bin/bash
# Copyright 2019 Google LLC
#
# Licensed under the the Apache License v2.0 with LLVM Exceptions (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://llvm.org/LICENSE.txt
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
SSD_ROOT="/mnt/disks/ssd0"
AGENT_ROOT="${SSD_ROOT}/agent"
# prepare root folder for Jenkins agent
mkdir -p "${AGENT_ROOT}"
chown -R buildkite:buildkite "${AGENT_ROOT}"
# prepare folder for ccache
mkdir -p "${CCACHE_PATH}"
chown -R buildkite:buildkite "${CCACHE_PATH}"
# TODO(kuhnel): wipe the disk(s) on startup
# set the token in the config file
sed -i -r s/token=\"[^\"]+\"/token=\"`cat /credentials/buildkite-token`\"/g /etc/buildkite-agent/buildkite-agent.cfg
# start the buildkite agent
buildkite-agent start

View file

@ -23,4 +23,4 @@ IMAGE_NAME="${1%/}"
cd "${DIR}/${IMAGE_NAME}"
docker build -t ${IMAGE_NAME} .
docker run -i -t ${IMAGE_NAME} ${2}
docker run -i -t -v ~/.llvm-premerge-checks:/credentials ${IMAGE_NAME} ${2}

View file

@ -0,0 +1,24 @@
#!/bin/bash
# Copyright 2019 Google LLC
#
# Licensed under the the Apache License v2.0 with LLVM Exceptions (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://llvm.org/LICENSE.txt
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#-------------------------------------------------------------------------------
# store the buildkite token as kubernetes secret
#
# Get the token from the website [1] and store it in this file locally in
# ~/.llvm-premerge-checks/buildkite-token
# Do not share this token with anyone!
# [1] https://buildkite.com/organizations/llvm-project/agents
kubectl create secret generic buildkite-token --from-file ~/.llvm-premerge-checks/buildkite-token