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

context_dir="./context"
dockerfile="py_tools_ds_ci.docker"
5
tag="py_tools_ds_ci:0.15.2"
Daniel Scheffler's avatar
Daniel Scheffler committed
6
gitlab_runner="py_tools_ds_gitlab_CI_runner"
Daniel Scheffler's avatar
Daniel Scheffler committed
7
8

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

15
16
17
18
# 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
19
echo "#### Create gitlab-runner (daemon) container with tag; ${tag}"
20
21
22
docker stop ${gitlab_runner}
docker rm ${gitlab_runner}
docker run \
23
24
25
26
    -d \
    --name ${gitlab_runner} \
    --restart always \
    -v /var/run/docker.sock:/var/run/docker.sock \
Daniel Scheffler's avatar
Daniel Scheffler committed
27
    gitlab/gitlab-runner:latest
Daniel Scheffler's avatar
Daniel Scheffler committed
28

29
# register the runner at the corresponding GitLab repository via a registration-token
Daniel Scheffler's avatar
Daniel Scheffler committed
30
31
32
33
34
echo "#### Register container at gitlab, get token here https://gitext.gfz-potsdam.de/danschef/py_tools_ds/settings/ci_cd"
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}"
35
36
# 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).
37
docker exec -it ${gitlab_runner} /bin/bash -c "\
38
export RUNNER_EXECUTOR=docker && \
Daniel Scheffler's avatar
Daniel Scheffler committed
39
gitlab-ci-multi-runner register \
40
41
42
  --non-interactive \
  --executor 'docker' \
  --docker-image '${tag}' \
Daniel Scheffler's avatar
Daniel Scheffler committed
43
  --url 'https://gitext.gfz-potsdam.de/ci' \
Daniel Scheffler's avatar
Daniel Scheffler committed
44
45
  --registration-token '${token}' \
  --description '${runner_name}' \
46
47
  --tag-list py_tools_ds_ci_client \
  --run-untagged='true' \
Daniel Scheffler's avatar
Daniel Scheffler committed
48
  --locked='true' \
49
  --access-level='not_protected' \
50
  --docker-pull-policy='never'
Daniel Scheffler's avatar
Daniel Scheffler committed
51
ls