build_testsuite_image.sh 1.99 KB
Newer Older
Daniel Scheffler's avatar
Daniel Scheffler committed
1 2 3
#!/usr/bin/env bash

context_dir="./context"
4
dockerfile="gms_preprocessing_ci.docker"
5
tag="gms_preprocessing_ci:0.18.5"
6
gitlab_runner="gms_preprocessing_gitlab_CI_runner"
Daniel Scheffler's avatar
Daniel Scheffler committed
7 8

echo "#### Build runner docker image"
9 10 11 12 13 14
docker rmi ${tag}
docker build ${context_dir} \
    --no-cache \
    -f ${context_dir}/${dockerfile} \
    -m 20G \
    -t ${tag}
Daniel Scheffler's avatar
Daniel Scheffler committed
15

16 17 18 19
# create the gitlab-runner docker container for the current project
# NOTE: The 'gitlab-runner' and 'gitlab-ci-multi-runner' services will run within this container.
#       The runner uses a 'config.toml' configuration file at /etc/gitlab-runner within the container which can be
#       modified through additional parameters of the 'gitlab-runner register' command.
Daniel Scheffler's avatar
Daniel Scheffler committed
20
echo "#### Create gitlab-runner (daemon) container with tag; ${tag}"
21 22 23 24 25 26 27 28
docker stop ${gitlab_runner}
docker rm ${gitlab_runner}
docker run \
    -d \
    --name ${gitlab_runner} \
    --restart always \
    -v /var/run/docker.sock:/var/run/docker.sock \
    gitlab/gitlab-runner:latest
Daniel Scheffler's avatar
Daniel Scheffler committed
29

30
# register the runner at the corresponding GitLab repository via a registration-token
31
echo "#### Register container at gitlab, get token here https://git.gfz-potsdam.de/geomultisens/gms_preprocessing/settings/ci_cd"
Daniel Scheffler's avatar
Daniel Scheffler committed
32 33 34 35
read -p "Please enter gitlab token: " token
echo ""
read -p "Please enter gitlab runner name: " runner_name
echo "New gitlab runner image will named  ${gitlab_runner}"
36 37 38 39 40 41 42 43
# NOTE: In case of locally stored images (like here), the docker pull policy 'never' must be used
#       (see https://docs.gitlab.com/runner/executors/docker.html#how-pull-policies-work).
docker exec -it ${gitlab_runner} /bin/bash -c "\
export RUNNER_EXECUTOR=docker && \
gitlab-ci-multi-runner register \
  --non-interactive \
  --executor 'docker' \
  --docker-image '${tag}' \
44
  --url 'https://git.gfz-potsdam.de/ci' \
Daniel Scheffler's avatar
Daniel Scheffler committed
45 46
  --registration-token '${token}' \
  --description '${runner_name}' \
47 48 49 50 51 52
  --tag-list gms_preprocessing_ci_client \
  --run-untagged='true' \
  --locked='true' \
  --access-level='not_protected' \
  --docker-pull-policy='never'
  "
Daniel Scheffler's avatar
Daniel Scheffler committed
53
ls