Skip to content

Commit

Permalink
services/pkg: create containers for buildbot and buildbot-builder
Browse files Browse the repository at this point in the history
  • Loading branch information
classabbyamp committed Sep 28, 2024
1 parent faeced9 commit 77f221b
Show file tree
Hide file tree
Showing 8 changed files with 194 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/pkg-buildbot-builder.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: buildbot-builder Service Container
on:
workflow_dispatch:
pull_request:
branches:
- master
paths:
- services/pkg/buildbot-builder/**
push:
branches:
- master
paths:
- services/pkg/buildbot-builder/**

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
main:
uses: ./.github/workflows/build-pkg.yml
with:
service_name: buildbot-builder
23 changes: 23 additions & 0 deletions .github/workflows/pkg-buildbot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: buildbot Service Container
on:
workflow_dispatch:
pull_request:
branches:
- master
paths:
- services/pkg/buildbot/**
push:
branches:
- master
paths:
- services/pkg/buildbot/**

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
main:
uses: ./.github/workflows/build-pkg.yml
with:
service_name: buildbot
27 changes: 27 additions & 0 deletions services/pkg/buildbot-builder/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM ghcr.io/void-linux/void-glibc-full:20240526R1 AS build

RUN xbps-install -Suy xbps && xbps-install -uy git go
ARG GO_XBPS_SRC_VERSION=4c394976975f7e84062f56d437b41a0d48043792
RUN env GOBIN=/usr/local/bin GOMODCACHE=/tmp/go \
go install -v github.com/Duncaen/go-xbps-src/cmd/xbps-src-make@$GO_XBPS_SRC_VERSION

FROM build AS buildbot-builder
RUN xbps-install -Suy xbps && xbps-install -uy python3 tini git curl bash make rsync
COPY --from=build /usr/local/bin/xbps-src-make /usr/local/bin/xbps-src-make
RUN rm -rf /var/cache/xbps && \
groupadd --gid 418 void-builder && \
useradd --uid 418 --gid 418 -G xbuilder -M -d /buildbot void-builder && \
mkdir /venv /buildbot && \
chown void-builder:void-builder /venv /buildbot
USER void-builder
# version must be synced with ../buildbot
RUN python3 -m venv /venv && \
/venv/bin/pip3 install wheel && \
/venv/bin/pip3 install 'buildbot-worker~=4.0.0'
WORKDIR /buildbot
RUN mkdir -p /buildbot && \
ln -sf /local/info /buildbot/info && \
ln -sf /local/xbps-src.conf /buildbot/.xbps-src.conf
COPY buildbot.tac /buildbot/
ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["/venv/bin/buildbot-worker", "start", "--nodaemon", "/buildbot"]
56 changes: 56 additions & 0 deletions services/pkg/buildbot-builder/buildbot.tac
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# vim: set filetype=python:

import os
import configparser

from buildbot_worker.bot import Worker

from twisted.application import service
from twisted.python.logfile import LogFile
from twisted.python.log import ILogObserver, FileLogObserver

basedir = '.'
rotateLength = 10000000
maxRotatedFiles = 10

# if this is a relocatable tac file, get the directory containing the TAC
if basedir == '.':
import os.path
basedir = os.path.abspath(os.path.dirname(__file__))

# note: this line is matched against to check that this is a worker
# directory; do not edit it.
application = service.Application('buildbot-worker')

logfile = LogFile.fromFullPath(
os.path.join(basedir, "twistd.log"), rotateLength=rotateLength,
maxRotatedFiles=maxRotatedFiles)
application.setComponent(ILogObserver, FileLogObserver(logfile).emit)

ini = configparser.ConfigParser()
ini.read_dict({'buildbot': {}, 'worker': {}})
ini.read('/local/config.ini')

buildmaster_host = ini['buildbot'].get('host', 'localhost')
port = ini['buildbot'].getint('worker-port', 9989)
workername = ini['worker'].get('name', 'example-worker')
with open("/secrets/buildbot/worker-password") as f:
passwd = f.read()
keepalive = ini['worker'].getint('keepalive', 600)
umask = None
maxdelay = ini['worker'].getint('maxdelay', 300)
numcpus = None
allow_shutdown = None
maxretries = None
use_tls = 0
delete_leftover_dirs = False
proxy_connection_string = None
protocol = 'pb'

s = Worker(buildmaster_host, port, workername, passwd, basedir,
keepalive, umask=umask, maxdelay=maxdelay,
numcpus=numcpus, allow_shutdown=allow_shutdown,
maxRetries=maxretries, protocol=protocol, useTls=use_tls,
delete_leftover_dirs=delete_leftover_dirs,
proxy_connection_string=proxy_connection_string)
s.setServiceParent(application)
19 changes: 19 additions & 0 deletions services/pkg/buildbot/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM ghcr.io/void-linux/void-glibc-full:20240526R1

RUN xbps-install -Suy xbps && xbps-install -uy python3 tini git curl
ARG THEME_VERSION=v0.1.0
# version must be synced with ../buildbot-worker
RUN python3 -m venv /venv && \
/venv/bin/pip3 install wheel && \
/venv/bin/pip3 install 'buildbot[tls,bundle]~=4.0.0' treq \
buildbot-prometheus buildbot-netauth \
git+https://github.com/void-linux/buildbot-theme.git@$THEME_VERSION
WORKDIR /buildbot
COPY buildbot.tac /buildbot/
COPY run.sh /
# buildbot config should be in its basedir
# buildbot upgrade-master hardcodes master.cfg
RUN ln -sf /local/buildbot.cfg /buildbot/buildbot.cfg && \
ln -sf /buildbot/buildbot.cfg /buildbot/master.cfg
ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["/bin/sh", "/run.sh"]
20 changes: 20 additions & 0 deletions services/pkg/buildbot/buildbot.tac
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# vim: set filetype=python:

import os
import sys

from twisted.application import service
from twisted.python.log import FileLogObserver
from twisted.python.log import ILogObserver

from buildbot.master import BuildMaster

basedir = os.path.abspath(os.path.dirname(__file__))

# note: this line is matched against to check that this is a buildmaster
# directory; do not edit it.
application = service.Application('buildmaster')
application.setComponent(ILogObserver, FileLogObserver(sys.stdout).emit)

m = BuildMaster(basedir, 'buildbot.cfg', umask=None)
m.setServiceParent(application)
12 changes: 12 additions & 0 deletions services/pkg/buildbot/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

: "${DB_UPGRADE:=$NOMAD_META_DB_UPGRADE}"

if [ "$DB_UPGRADE" = "true" ]; then
until /venv/bin/buildbot upgrade-master /buildbot; do
echo "upgrading buildbot installation..."
sleep 1
done
fi

exec /venv/bin/buildbot start --nodaemon /buildbot
14 changes: 14 additions & 0 deletions services/pkg/docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,20 @@ target "infra-alps" {
context = "services/pkg/alps/"
}

target "infra-buildbot" {
inherits = ["_common"]
platforms = ["linux/amd64"]
args = { "LIBC" = "glibc" }
context = "services/pkg/buildbot/"
}

target "infra-buildbot-builder" {
inherits = ["_common"]
platforms = ["linux/amd64"]
args = { "LIBC" = "glibc" }
context = "services/pkg/buildbot-builder/"
}

target "infra-debuginfod" {
inherits = ["_common-musl"]
context = "services/pkg/debuginfod/"
Expand Down

0 comments on commit 77f221b

Please sign in to comment.