From e7459095cfd1109756312a030842bbb3aad8c733 Mon Sep 17 00:00:00 2001 From: Pierre Tardy Date: Thu, 15 Dec 2016 13:30:29 +0100 Subject: [PATCH] add pypy dockerfile --- pypy/master/Dockerfile | 2 ++ pypy/master/buildbot.tac | 16 ++++++++++ pypy/master/requirements.txt | 2 ++ pypy/master/start_buildbot.sh | 56 +++++++++++++++++++++++++++++++++++ 4 files changed, 76 insertions(+) create mode 100644 pypy/master/Dockerfile create mode 100644 pypy/master/buildbot.tac create mode 100644 pypy/master/requirements.txt create mode 100755 pypy/master/start_buildbot.sh diff --git a/pypy/master/Dockerfile b/pypy/master/Dockerfile new file mode 100644 index 0000000..7390d63 --- /dev/null +++ b/pypy/master/Dockerfile @@ -0,0 +1,2 @@ +from pypy:2-onbuild +CMD /usr/src/app/start_buildbot.sh diff --git a/pypy/master/buildbot.tac b/pypy/master/buildbot.tac new file mode 100644 index 0000000..1d8d3ab --- /dev/null +++ b/pypy/master/buildbot.tac @@ -0,0 +1,16 @@ +import sys + +from buildbot.master import BuildMaster +from twisted.application import service +from twisted.python.log import FileLogObserver, ILogObserver + +basedir = '/usr/src/app' +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, FileLogObserver(sys.stdout).emit) + +m = BuildMaster(basedir, configfile, umask=None) +m.setServiceParent(application) diff --git a/pypy/master/requirements.txt b/pypy/master/requirements.txt new file mode 100644 index 0000000..2f8afc7 --- /dev/null +++ b/pypy/master/requirements.txt @@ -0,0 +1,2 @@ +buildbot[bundle] +psycopg2cffi-compat diff --git a/pypy/master/start_buildbot.sh b/pypy/master/start_buildbot.sh new file mode 100755 index 0000000..8bd4f81 --- /dev/null +++ b/pypy/master/start_buildbot.sh @@ -0,0 +1,56 @@ +#!/bin/sh + +# startup script for purely stateless master + +# we download the config from an arbitrary curl accessible tar.gz file (which github can generate for us) + +B=`pwd` + +if [ -z "$BUILDBOT_CONFIG_URL" ] +then + if [ ! -f "$B/master.cfg" ] + then + echo No master.cfg found nor $$BUILDBOT_CONFIG_URL ! + echo Please provide a master.cfg file in $B or provide a $$BUILDBOT_CONFIG_URL variable via -e + exit 1 + fi + +else + BUILDBOT_CONFIG_DIR=${BUILDBOT_CONFIG_DIR:-config} + mkdir -p $B/$BUILDBOT_CONFIG_DIR + # if it ends with .tar.gz then its a tarball, else its directly the file + if echo "$BUILDBOT_CONFIG_URL" | grep '.tar.gz$' >/dev/null + then + until curl -sL $BUILDBOT_CONFIG_URL | tar -xz --strip-components=1 --directory=$B/$BUILDBOT_CONFIG_DIR + do + echo "Can't download from \$BUILDBOT_CONFIG_URL: $BUILDBOT_CONFIG_URL" + sleep 1 + done + + ln -sf $B/$BUILDBOT_CONFIG_DIR/master.cfg $B/master.cfg + + if [ -f $B/$BUILDBOT_CONFIG_DIR/buildbot.tac ] + then + ln -sf $B/$BUILDBOT_CONFIG_DIR/buildbot.tac $B/buildbot.tac + fi + else + until curl -sL $BUILDBOT_CONFIG_URL > $B/master.cfg + do + echo "Can't download from $$BUILDBOT_CONFIG_URL: $BUILDBOT_CONFIG_URL" + done + fi +fi +# copy the default buildbot.tac if not provided by the config +if [ ! -f $B/buildbot.tac ] +then + cp /usr/src/buildbot/contrib/docker/master/buildbot.tac $B +fi +# 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