Introducing SlicerBuildEnvironment project


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.


The SlicerBuildEnvironment project has the following organization:

  |--- 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).


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


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
mkdir -p $ROOT_DIR

cd ${ROOT_DIR}

# Download sources
svn co 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 \
  -DSlicer_USE_SimpleITK: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

cd ${ROOT_DIR}


# Download extension source
git clone git:// ${EXTENSION_NAME}

# Configure the extension
slicer-buildenv-qt4-ubuntu1004 cmake \
  -GNinja \

# 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


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.


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.


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