This repository contains an inofficial Docker image for buildbot, the Continuous Integration framework.
2.5.0
,2.5
,2
,latest
2.4.1
,2.4
2.4.0
2.3.1
,2.3
2.3.0
2.2.0
,2.2
2.1.0
,2.1
2.0.1
,2.0
1.8.2
,1.8
,1
1.8.1
1.8.0
- Where to file issues:
https://github.com/cjolowicz/docker-buildbot/issues - Maintained by:
Claudio Jolowicz - Supported Docker versions:
the latest release - Changelog:
https://github.com/cjolowicz/docker-buildbot/blob/master/CHANGELOG.md
Buildbot is an open-source framework for automating software build, test, and release processes. Buildbot can automate all aspects of the software development cycle: Continuous Integration, Continuous Deployment, Release Management, and any other process you can imagine. Buildbot is a framework in which you implement a system that matches your workflow and grows with your organization.
The image runs the buildbot master with a sample configuration.
- Getting started
- Modes of operation
- Sample configuration
- Use with Docker Compose
- Use with Docker Swarm
- Use with Docker CLI
To get started quickly, clone the Git repository and run docker-compose up
from inside it. This will start a buildbot master container with sensible
defaults.
When the container has started up, point your browser to http://localhost:8010 to access the web interface. Navigate to Builds > Builders > hello-world, and click the trigger button.
To stop the container, press CTRL+C
in the terminal where docker-compose
was
invoked.
The buildbot architecture consists of a single build master and one or more workers, connected in a star topology. This image supports different modes of operation, which may be combined freely:
- Workers can be run on external hosts.
- Workers can be run inside the master container (local worker).
- Workers can be run as sibling containers.
- Workers can be spawned on demand as sibling containers, by the master.
Both master and workers can also be run as services on a Docker Swarm cluster. For example, it is possible to deploy the buildbot master as a Docker service, with workers being spawned on demand and automatically load-balanced across the available swarm nodes.
The sample build downloads the source tarball from buildbot's hello-world repository and runs its test suite. The build must be triggered explicitly using the trigger button on the builder page.
The sample configuration provided with this image demonstrates the use of different types of workers. The behaviour depends on whether the Docker daemon is accessible from the container.
If the Docker daemon is accessible from the container:
- If the daemon is configured as a manager node on a Docker Swarm,
DockerSwarmLatentWorker
from the buildbot-docker-swarm-worker plugin is used. This allows the master to spawn workers as swarm services on demand. - Otherwise,
worker.DockerLatentWorker
is used. This allows the master to spawn workers as sibling containers on demand.
If the Docker daemon is not accessible from the container:
- If the
WORKERNAME
andWORKERPASS
environment variables are provided,worker.Worker
is used. This allows a worker to connect to the master at port 9989 using the given credentials. - Otherwise,
worker.LocalWorker
is used. This will run a worker on the same host and in the same process as the buildbot master.
Use the supplied docker-compose.yml file to start the master container with sensible defaults:
$ docker-compose up -d
Use the supplied buildbot.yml file to start the master container as a service on Docker Swarm:
$ eval $(scripts/buildbot-env.sh)
$ docker stack deploy -c buildbot.yml buildbot
The script buildbot-env.sh prints shell commands to
set up environment variables for buildbot deployment. The output of this script
should be evaluated by the calling shell, as shown above. This is required after
every change to master.cfg
, for the new configuration to get deployed to the
stack.
If DOCKER_HOST
is set in the environment, its value is used to provide a
default for BUILDBOT_URL
.
This section outlines important options when starting the container explicitly
using docker run
.
- Reaping zombie processes
- Exposing the web port
- Exposing the buildbot port
- Configuring the buildbot URL
- Using a named volume for program data
- Bind-mounting the Docker daemon socket
- User and group ID
- Configuring buildbot
- Running builds in the master container
- Running builds in worker containers
- Spawning workers as sibling containers
- Spawning workers on a Docker Swarm cluster
$ docker run --init -d cjolowicz/buildbot
You should always pass the --init
option to ensure zombie processes created by
builds are reaped during the lifetime of each container.
If your version of Docker does not support the --init
option, you can use the
following simple Dockerfile
to generate an image with
tini installed:
FROM cjolowicz/buildbot
RUN apk add --no-cache tini
ENTRYPOINT ["/sbin/tini", "docker-entrypoint.sh"]
Then build the image with docker build -t custom-buildbot .
and run it as
follows:
$ docker run -d custom-buildbot
$ docker run --init -p 8010:8010 -d cjolowicz/buildbot
When the container has started up, point your browser to http://localhost:8010
to access the web interface. This is not required if you provide access to the
web interface by other means, such as an nginx
container running on the same
Docker network.
$ docker run --init -p 9989:9989 -d cjolowicz/buildbot
Expose port 9989 to allow buildbot workers to access the master at this port on the Docker host. This is not required if workers are run as containers on the same Docker network.
$ docker run --init -e BUILDBOT_URL=http://some-buildbot-host/ -d cjolowicz/buildbot
Use the BUILDBOT_URL
environment variable to configure the external URL at
which the web interface is accessed. If BUILDBOT_URL
is unset or empty, it
defaults to http://localhost:8010
.
An incorrect buildbot URL results in errors in the web interface, because requests to the API violate the Same Origin Policy. An example would be the following message when triggering a build:
"invalid origin"
$ docker run --init -v buildbot:/var/lib/buildbot -d cjolowicz/buildbot
Program data such as the buildbot database is stored in a volume mounted at
/var/lib/buildbot
in the container. It is recommended to provide a named
volume to share this data between successive runs of the image.
$ docker run --init -v /var/run/docker.sock:/var/run/docker.sock -d cjolowicz/buildbot
The master container can spawn workers as sibling containers on demand. These containers are stopped and removed when the build is finished. This requires that the Docker daemon socket is bind-mounted into the master container.
Note that this has important security implications. Essentially, access to the Docker daemon socket implies root privileges on the Docker host.
On startup, the image drops privileges for the buildbot process using su-exec:
$ id
uid=1000(buildbot) gid=1000(buildbot) groups=1000(buildbot)
If the Docker daemon socket is bind-mounted into the container, the process runs with the group ID of the socket owner instead.
Buildbot is configured using the file /etc/buildbot/master.cfg
in the
container. You can provide your own configuration by bind-mounting it onto this
location:
$ docker run --init -v /host/path/master.cfg:/etc/buildbot/master.cfg:ro -d cjolowicz/buildbot
This can also be accomplished more cleanly using a simple Dockerfile
:
FROM cjolowicz/buildbot
COPY master.cfg /etc/buildbot/master.cfg
Then build the image with docker build -t custom-buildbot .
and run it as
follows:
$ docker run -d custom-buildbot
Builds can be run in the master container using worker.LocalWorker
in the
buildbot configuration, as demonstrated by the sample
master.cfg.
Ensure that the master image has the required build toolchain installed. The following Alpine packages are already installed:
You can install additional tools using the
apk package
manager in your own Dockerfile
. Note that Alpine uses
musl instead of
glibc.
Builds can be run in long-running sibling containers using worker.Worker
in
the master configuration. Supply the master hostname, worker name, and worker
password to the worker container via environment variables:
$ export BUILDMASTER=buildbot
$ export WORKERNAME=worker
$ docker network create buildbot-net
$ docker run --init --network buildbot-net --name $BUILDMASTER \
-p 8010:8010 -d cjolowicz/buildbot
$ docker run --init --network buildbot-net --name $WORKERNAME \
-e BUILDMASTER -e WORKERNAME -e WORKERPASS=secret \
-d cjolowicz/buildbot-worker
See cjolowicz/buildbot-worker for a collection of buildbot worker images for various platforms.
The master container can spawn buildbot workers as sibling containers on demand
using worker.DockerLatentWorker
. Unlike long-running worker containers,
on-demand workers are provided automatically with an environment that allows
them to connect back to the master.
This requires that the Docker daemon socket is bind-mounted into the master container, as described above.
The master container can spawn buildbot workers as Docker Swarm services on
demand using worker.DockerSwarmLatentWorker
from the
buildbot-docker-swarm-worker
plugin.
This requires that the buildbot master is started as a Docker service on the manager node of the Docker Swarm, and that the Docker daemon socket is bind-mounted into the master container.
Consider using the provided buildbot.yml to deploy a Docker stack with sensible defaults. See the section about Docker Swarm for details.