I'm trying to compose the simplest possible docker buildbot master image that runs buildbot start
in ENTRYPOINT/CMD
Dockerfile
instructions.
I've tried to use a lot of combinations of dumb-init
, gosu
and exec
, but with no success.
The situation is as follows:
When I try to run deamonized buildroot with the command
docker run -d -v $local/vol/bldbot/master:/var/lib/buildbot buildbot-master-test
, the container starts successfully, but it is terminated abruptly. The log looks as follows:[timestamp] [-] Log opened.
[timestamp] [-] twistd 16.0.0 (/usr/bin/python 2.7.12) starting up.
[timestamp] [-] reactor class: twisted.internet.epollreactor.EPollReactor.
[timestamp] [-] Starting BuildMaster -- buildbot.version: 0.9.2
[timestamp] [-] Loading configuration from '/var/lib/buildbot/master.cfg'
[timestamp] [-] Setting up database with URL 'sqlite:/state.sqlite'
[timestamp] [-] setting database journal mode to 'wal'
[timestamp] [-] doing housekeeping for master 1 c8aa8b0d5ca3:/var/lib/buildbot
[timestamp] [-] adding 1 new changesources, removing 0
[timestamp] [-] adding 1 new builders, removing 0
[timestamp] [-] adding 2 new schedulers, removing 0
[timestamp] [-] No web server configured on this master
[timestamp] [-] adding 1 new workers, removing 0
[timestamp] [-] PBServerFactory starting on 9989
[timestamp] [-] Starting factory
[timestamp] [-] BuildMaster is runningWhen I run the container in an interactive mode with the command
docker run --rm -it -v $local/vol/bldbot/master:/var/lib/buildbot buildbot-master-test /bin/sh
and next I run the commandbuildbot start
all works like charm.
I've already studied the content of official buildbot master docker image, i.e. buildbot/buildbot-master
. I see that authors decided to use the command exec twistd -ny $B/buildbot.tac
in start_buildbot.sh, not their own buildbot start
.
So the question is, how to compose the ENTRYPOINT/CMD
instructions in the Dockerfile that runs simply buildbot start
.
ADDENDUM 1
Dockerfile
content
FROM alpine:3.4
ENV BASE_DIR=/var/lib/buildbot SRC_DIR=/usr/src/buildbot
COPY start $SRC_DIR/
RUN \
echo @testing http://nl.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories && \
echo @community http://nl.alpinelinux.org/alpine/edge/community >> /etc/apk/repositories && \
apk add --no-cache \
python \
py-pip \
py-twisted \
py-cffi \
py-cryptography@community \
py-service_identity@community \
py-sqlalchemy@community \
gosu@testing \
dumb-init@community \
py-jinja2 \
tar \
curl && \
# install pip dependencies
pip install --upgrade pip setuptools && \
pip install "buildbot" && \
rm -r /root/.cache
WORKDIR $BASE_DIR
RUN \
adduser -D -s /bin/sh bldbotmaster && \
chown bldbotmaster:bldbotmaster .
VOLUME $BASE_DIR
CMD ["dumb-init", "/usr/src/buildbot/start","buildbot","master"]
ADDENDUM 2
start
script content
#!/bin/sh
set -e
BASE_DIR=/var/lib/buildbot
if [[ "$1" = 'buildbot' && "$2" = 'master' ]]; then
if [ -z "$(ls -A "$BASE_DIR/master.cfg" 2> /dev/null)" ]; then
gosu bldbotmaster buildbot create-master -r $BASE_DIR
gosu bldbotmaster cp $BASE_DIR/master.cfg.sample $BASE_DIR/master.cfg
fi
exec gosu bldbotmaster buildbot start $BASE_DIR
fi
exec "$@"
start
script which you copy from host to image? – Ichneumonexec
or withCMD ["/usr/src/buildbot/start","buildbot","master"]
yield the same effect. – Footsiebuildbot stop
and I see nice messages in thetwistd.log
log saying that the SIGTERM is received, shutdown procedure initiated and finally BuildMaster server is stopped. As you can see there is not such a messages in the log, when I run in deamonized mode. – Footsie