— This guide applies to Docker for Linux, Docker for macOS and Docker for Windows 10/11 (BUT ONLY in ‘Linux containers’ mode) —

1. Use an already existing Docker image and run a Docker container to compile

start a container in interactive mode: docker run -it your_Docker_ID/your_docker_image

if needed later, to restart a container in interactive mode: docker start CONTAINER_ID -i (to find CONTAINER_ID: docker ps -a)

2. Create a Docker image

build the image: docker build -t your_docker_image .

push your Docker image to your personal account on Docker Hub (https://hub.docker.com):

3. Enable continuous integration with GitLab

3.1. With a ‘Linux Server’ (or a ‘Linux VM’)

WE ARE HERE for Docker but first of all here is an example of continuous integration WITHOUT Docker… ;-) So you can go to the next section directly if you want !

[ USELESS if you already have a dedicated ‘Linux Server’ !

choose ‘shell’ as ‘runner executor’ when asked

USELESS if you already have a dedicated ‘Linux Server’ ! ]

###################
# CONF1 - Release #
###################
#
conf1 - Release:
  tags:
    - my_tag1,my_tag2
  script:
    - mkdir build; cd build
    - cmake .. -DCMAKE_BUILD_TYPE=Release
    - make -j 3
    - xvfb-run --server-args="-screen 0, 1280x1024x24" ctest -j 3 --output-on-failure
    - (...my commands which are good for "myproject"...)

#################
# CONF2 - Debug #
#################
#
conf2 - Debug:
  tags:
    - my_tag1,my_tag2
  script:
    - mkdir build; cd build
    - cmake .. -DCMAKE_BUILD_TYPE=Debug
    - make -j 3
    - xvfb-run --server-args="-screen 0, 1280x1024x24" ctest -j 3 --output-on-failure
    - (...my commands which are good for "myproject"...)

3.2. With Docker

[ USELESS if you already have a dedicated ‘Linux Server’ with Docker !

choose ‘docker’ as ‘runner executor’ when asked

USELESS if you already have a dedicated ‘Linux Server’ with Docker ! ]

.linux_build_template_0x - Release: &linux_build_definition_0x-release
  script:
    - mkdir build; cd build
    - cmake .. -DCMAKE_BUILD_TYPE=Release
    - make -j 3
    - xvfb-run --server-args="-screen 0, 1280x1024x24" ctest -j 3 --output-on-failure
    - (...my commands which are good for "myproject"...)

##################
# CONF1 - u18.04 #
##################
#
conf1 - u18.04:
  tags:
    - my_tag1,my_tag2
  image: my_dockerhub_name/my_ubuntu_18.04-for-myproject
  <<: *linux_build_definition_0x-release

##################
# CONF2 - u20.04 #
##################
#
conf2 - u20.04:
  tags:
    - my_tag1,my_tag2
  image: my_dockerhub_name/my_ubuntu_20.04-for-myproject
  <<: *linux_build_definition_0x-release
Docker Install
Docker Windows