diff --git a/Dockerfile.cabotage b/Dockerfile.cabotage new file mode 100644 index 00000000..74e543f1 --- /dev/null +++ b/Dockerfile.cabotage @@ -0,0 +1,62 @@ +# Adapted from https://github.com/buildbot/buildbot/raw/refs/heads/master/Dockerfile.master + +# Build the environment in an intermediate image, then copy it over to final. + +ARG DEBIAN_VERSION="trixie" + +FROM --platform=${BUILDPLATFORM} docker.io/library/debian:${DEBIAN_VERSION} AS buildbot-build + +RUN \ + apt-get update && \ + apt-get -y upgrade && \ + apt-get -y install --no-install-recommends --no-install-suggests -q \ + ca-certificates \ + curl \ + make \ + git \ + build-essential \ + python3-dev \ + virtualenv \ + libpq-dev \ + && \ + rm -rf /var/lib/apt/lists/* + +# Copy requirements separately to avoid unnecessary rebuilds. +COPY requirements*.txt /srv/buildbot/ + +RUN virtualenv --python=python3 /srv/buildbot/venv && \ + /srv/buildbot/venv/bin/pip3 install -r /srv/buildbot/requirements-*.txt + +COPY . /srv/buildbot + +# Copy docker-specific config into place +COPY docker/buildbot.tac /srv/buildbot/master/buildbot.tac +COPY docker/start_buildbot.sh /srv/buildbot/start_buildbot.sh + + +#============================================================================== +# Build the final image here. Use build artifacts from the buildbot-build +# container. + +FROM docker.io/library/debian:${DEBIAN_VERSION}-slim AS buildbot-master + +RUN \ + apt-get update && \ + apt-get -y upgrade && \ + apt-get -y install -q \ + curl \ + dumb-init \ + git \ + libpq5 \ + libcairo2 \ + openssh-client \ + python3 \ + tar \ + tzdata \ + && \ + rm -rf /var/lib/apt/lists + +COPY --from=buildbot-build /srv/buildbot /srv/buildbot + +WORKDIR /srv/buildbot +CMD ["dumb-init", "/srv/buildbot/start_buildbot.sh"] diff --git a/docker/buildbot.tac b/docker/buildbot.tac new file mode 100644 index 00000000..20bf02ce --- /dev/null +++ b/docker/buildbot.tac @@ -0,0 +1,27 @@ +import os +import sys + +from twisted.application import service +from twisted.logger import ILogObserver +from twisted.logger import textFileLogObserver +from twisted.logger import LogLevelFilterPredicate +from twisted.logger import FilteringLogObserver + +from buildbot.master import BuildMaster + +basedir = os.environ.get("BUILDBOT_BASEDIR", + os.path.abspath(os.path.dirname(__file__))) +configfile = 'master.cfg' + +# 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, + FilteringLogObserver( + textFileLogObserver(sys.stdout), predicates=[LogLevelFilterPredicate()] + ), +) + +m = BuildMaster(basedir, configfile, umask=None) +m.setServiceParent(application) diff --git a/docker/start_buildbot.sh b/docker/start_buildbot.sh new file mode 100755 index 00000000..b7453cdb --- /dev/null +++ b/docker/start_buildbot.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# Adapted from https://github.com/buildbot/buildbot/raw/refs/heads/master/master/docker/start_buildbot.sh + +# startup script for purely stateless master + +export PATH="/srv/buildbot/venv/bin:$PATH" + +B=/srv/buildbot/master + +# Fixed buildbot master not start error in docker +rm -f "$B/twistd.pid" +# wait for db to start by trying to upgrade the master +until buildbot upgrade-master "$B" +do + echo "Can't upgrade master yet. Waiting for database ready?" + sleep 1 +done + +# we use exec so that twistd use the pid 1 of the container, and so that signals are properly forwarded +exec twistd -ny "$B/buildbot.tac"