Development Environment Setup

BuildGrid comes with Docker support for local development.

Caution

The Docker manifests are intended to be use for local development only. Do not use them in production.

Please consult the Get Started with Docker guide if you are looking for instructions on how to setup Docker on your machine.

Docker build

BuildGrid ships a Dockerfile manifest for building images from source using docker build. In order to produce a buildgrid:local base image, run:

git clone https://gitlab.com/BuildGrid/buildgrid.git
cd buildgrid
docker build --tag buildgrid:local .

Note

The image built will contain the Python sources, including example configuration files. The main endpoint is the bgd CLI tools and the default command shall run the BuildGrid server loading default configuration.

Once completed, you can check that build succeed by locally starting in a container the BuildGrid server with default configuration. Simply run:

docker run --interactive --publish 50051:50051 buildgrid:local

Hint

You can run any of the BuildGrid CLI tool using that image, simply pass extra arguments to docker run the same way you would pass them to bgd.

Bear in mind that whenever the source code or the configuration files are updated, you must re-build the image.

Docker Compose

BuildGrid ships a docker-compose.yml manifest for building and running a grid locally using docker-compose. This is the recommended way of running a simple demo grid.

In order to produce a buildgrid:local base image, run:

git clone https://gitlab.com/BuildGrid/buildgrid.git
cd buildgrid
docker-compose build

Once completed, you can start a simple grid by running:

docker-compose up

Note

The grid is composed of five containers: - A PostgreSQL database available at localhost:5432. - An execution service available at http://localhost:50051. - A CAS service available at http://localhost:50052. - An ActionCache service available at http://localhost:50053. - A single unnamed instance with one host-tools based worker bot attached.

Hint

You can spin up more bots by using docker-compose scaling capabilities:

docker-compose up --scale bots=12

Hint

The contained services configuration files are bind mounted into the container, no need to rebuild the base image on configuration update. Configuration files are read from:

  • data/config/controller.conf for the Execution service.

  • data/config/storage.conf for the CAS service.

  • data/config/cache.conf for the ActionCache service

Minimal Docker Compose

BuildGrid also provides a docker-compose-bazel.yml manifest, which deploys a minimal BuildGrid that is easy to get working with Bazel. To use it, first build the buildgrid:local base image as above:

git clone https://gitlab.com/BuildGrid/buildgrid.git
cd buildgrid
docker-compose -f docker-compose-bazel.yml build

Once completed, you can start a simple grid by running:

docker-compose -f docker-compose-bazel.yml up

Note

The grid is composed of three containers:

  • A PostgreSQL database available at localhost:5432.

  • Execution, CAS, and ActionCache services available at http://localhost:50051.

  • A single unnamed instance with one host-tools based worker bot attached.

Hint

You can spin up more bots by using docker-compose scaling capabilities:

docker-compose -f docker-compose-bazel.yml up --scale bots=12

Hint

The configuration file is bind mounted into the container, no need to rebuild the base image on configuration update. Configuration files are read from:

  • data/config/bazel.conf for the BuildGrid services.

Interactive Development with tox

Support for development using tox is available out of the box with BuildGrid.

Tox handles installing virtualenvs with all your dependencies, based on the use case. So for example to create a virtualenv with the dependencies sufficient to run a simple BuildGrid server, we provide the “server” environment:

tox -e server

This will install the virtualenv and then run bgd server start data/config/default.conf -vvv within that env. For the bot, you can start a host-tools bot using tox:

tox -e bot host-tools

For development, the venv virtualenv is useful as that does not run a preconfigured command. To run the tests from the virtualenv you simply specify the venv environment and then whatever command you wish to run after that:

tox -e venv -- pytest
# Or run a single test file, for example test_index.py:
tox -e venv -- pytest  tests/cas/index/test_index.py
# Or to simply run pep8:
tox -e venv -- pytest --pep8 -m pep8

You can use tox to build these docs themselves too, there is an environment for that:

tox -e docs

A full list of available environments is available in tox.ini.