Skip to content

Files

Latest commit

 

History

History

dockerfiles

CMake Examples with Docker

Docker

Docker allows you to package software in a container which contains a filesystem with all dependencies. This allows having containers which include everything needed to run and test our examples. And as a result of packaging all dependencies we can create containers to include different versions of cmake so that it is possible to easily make sure our examples work for many cmake versions.

Building

To build a container from the this directory run the following:

$ docker build --rm -f <dockerfile> -t <container tag> .

For example:

$ docker build --rm -f ubuntu14.04-cmake-3.5.1 -t matrim/cmake-examples:3.5.1 .

In this example the tag is created as follows

<docker user>/<repository>:<cmake version>

This will tag the container as belong to my repository with the label of the container being the version of cmake installed.

Pre-build Images

I have pre-build images and pushed them to the docker hub in the repository matrim/cmake-examples.

The current usable images include the following versions of cmake:

  • Ubuntu 16.04 with CMake 3.5.1

    $ docker pull docker pull matrim/cmake-examples:3.5.1
  • Ubuntu 16.04 with CMake 3.10.3

    $ docker pull docker pull matrim/cmake-examples:3.10.3

Some old images which work with older version of the repository include:

  • Ubuntu 14.04 with CMake 2.8.12.2

    $ docker pull docker pull matrim/cmake-examples:2.8.12.2
  • Ubuntu 14.04 with CMake 3.4.3

    $ docker pull docker pull matrim/cmake-examples:3.4.3

Running

When run the images will automatically create a non root user called devuser, with a default command to launch a bash shell in the users home directory.

If you want to set the UID and GID for this user you can pass them in via the environment variables DEV_UID and DEV_GID

For example

docker run -e DEV_UID=`id -u` -e DEV_GID=`id -u` -it matrim/cmake-examples:3.5.1

To build the full set of cmake-examples test cases you can run:

docker run -it matrim/cmake-examples:3.5.1
git clone https://github.com/ttroy50/cmake-examples.git
cd cmake-examples
./test.sh

If you already have a checkout of the cmake-examples you can load the directory as a docker volume.

Below is an example of loading a volume and automatically running all cmake-example test cases:

docker run --rm -e DEV_UID=`id -u` -e DEV_GID=`id -u` -v /checkout/directory:/data/code -it matrim/cmake-examples:3.5.1 /data/code/test.sh