Introducing SlicerBuildEnvironment project

overview

To streamline the continuous integration and allow anyone to easily reproduce builds, we created a new project. Currently, it contains only a Docker directory that itself contain a sub-directory for each build environment.

table of contents

docker terminology

For the one who are not familiar with Docker, it is somewhat like a light-weight virtual machine that can start very efficiently.

Before diving into the details of this project, some terminology:

  • host: This is your workstation running your preferred operating system.
  • container: This is what is created after starting up a docker image.
  • docker image: It is pre-generated using a recipe (the Dockerfile) and can be downloaded on the host.
  • docker client: To keep things simple, this is the tool used to run a docker image.

organization

The SlicerBuildEnvironment project has the following organization:

SlicerBuildEnvironment
  |
  |--- Docker
          |--- qt4-centos5
          |          |--- Dockerfile
          |
          |--- qt4-ubuntu1004
          |          |--- Dockerfile
          |
          |--- qt5-centos7
          |          |--- Dockerfile
          |
          |--- Makefile

Each sub-directory (e.g qt5-centos7) contains a Dockerfile allowing to generate a reusable build environment (or docker image). That build environment includes a version of qt (e.g qt5) and is based on a given operating system (e.g centos5).

dockbuild

The interesting part is that the recipe associated with each SlicerBuildEnvironment image is only responsible to install (or build) Qt, the remaining of the tools forming the complete compiling environment are provided by some other base images provided by the dockbuild project.

dockbuild is a project responsible to create base docker image that includes a tested compiling environment, latest git version, cmake, ninja, python 3 and openssh-client. And also a convenience entrypoint allowing to automatically mount the current working directory into the image.

dockbuild was inspired by dockcross, a collection of docker image providing cross-compiling enviroment. It even re-use the same tests and entrypoint script.

available build environment

slicer/buildenv-qt4-ubuntu1004:latest
slicer/buildenv-qt4-centos5:latest
slicer/buildenv-qt5-centos7:latest

step-by-step: (1) configure, build and package Slicer

The following steps will:

  • download Slicer 4.8.1 source code
  • download the associated build environment
  • configure, build and package Slicer
ROOT_DIR=/tmp/Slicer481
mkdir -p $ROOT_DIR

cd ${ROOT_DIR}

# Download sources
svn co http://svn.slicer.org/Slicer4/branches/Slicer-4-8 Slicer -r 26813

# Download corresponding build environment and generate convenience script
docker run --rm slicer/buildenv-qt4-ubuntu1004 > ~/bin/slicer-buildenv-qt4-ubuntu1004
chmod u+x ~/bin/slicer-buildenv-qt4-ubuntu1004

# Configure Slicer
slicer-buildenv-qt4-ubuntu1004 cmake \
  -BSlicer-build -HSlicer \
  -GNinja \
  -DCMAKE_BUILD_TYPE:STRING=Release \
  -DSlicer_USE_PYTHONQT_WITH_TCL:BOOL=OFF \
  -DSlicer_BUILD_CLI:BOOL=OFF \
  -DSlicer_USE_SimpleITK:BOOL=OFF \
  -DBUILD_TESTING:BOOL=OFF

# Build Slicer
slicer-buildenv-qt4-ubuntu1004 cmake --build Slicer-build

# Package Slicer
slicer-buildenv-qt4-ubuntu1004 cmake --build Slicer-build\Slicer-build --target package

step-by-step: (2) configure, build and package a Slicer extension

The following steps will:

  • download an extension source code
  • configure, build and package the extension using the build generated above
ROOT_DIR=/tmp/Slicer481

cd ${ROOT_DIR}

EXTENSION_NAME=ImageMaker

# Download extension source
git clone git://github.com/finetjul/ImageMaker ${EXTENSION_NAME}

# Configure the extension
slicer-buildenv-qt4-ubuntu1004 cmake \
  -B${EXTENSION_NAME}-build -H${EXTENSION_NAME} \
  -GNinja \
  -DCMAKE_BUILD_TYPE:STRING=Release \
  -DSlicer_DIR:PATH=/work/Slicer-build/Slicer-build


# Hint: /work is the working directory in the image, it corresponds to 
#       the directory from which the script `slicer-buildenv-qt4-ubuntu1004` is called.


# Build the extension
slicer-buildenv-qt4-ubuntu1004 cmake --build ${EXTENSION_NAME}-build

# Package the extension
slicer-buildenv-qt4-ubuntu1004 cmake --build ${EXTENSION_NAME}-build --target package

summary

We presented a collection of Linux based build environment allowing to reproduce build of Slicer, Slicer extension or literally any other project with similar requirements.

This build environment requires to have docker installed and can be used on Linux, macOS or Windows host.

next

In follow-up posts, we will:

  • explain how to run the tests
  • describe the slicer/slicer-base docker images used for continous integration
  • introduce the slicer/slicer image (it will be available shortly, and will be a light weight images including Slicer binaries)

In the future, we also plan to add windows docker images, and/or vagrant cookbook to create Windows virtual machines.

2 Likes

Thank you @jcfr, this is great! It could be useful to have this nice overview in the SlicerBuildEnvironment documentation pages, too.

Thanks for the feedback.

The project README has been updated.

1 Like