build_arosics_testsuite_image.sh 1.94 KB
Newer Older
1
2
3
4
#!/usr/bin/env bash

context_dir="./context"
dockerfile="arosics_ci.docker"
5
tag="arosics_ci:0.9.20"
Daniel Scheffler's avatar
Daniel Scheffler committed
6
gitlab_runner="arosics_gitlab_CI_runner"
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}
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.
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
29

Daniel Scheffler's avatar
Daniel Scheffler committed
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/danschef/arosics/settings/ci_cd"
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
# 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).
38
docker exec -it ${gitlab_runner} /bin/bash -c    "\
39
40
41
42
43
export RUNNER_EXECUTOR=docker && \
gitlab-ci-multi-runner register \
  --non-interactive \
  --executor 'docker' \
  --docker-image '${tag}' \
44
  --url 'https://git.gfz-potsdam.de/ci' \
45
46
  --registration-token '${token}' \
  --description '${runner_name}' \
47
48
49
50
51
  --tag-list arosics_ci_client \
  --run-untagged='true' \
  --locked='true' \
  --access-level='not_protected' \
  --docker-pull-policy='never'
Daniel Scheffler's avatar
Daniel Scheffler committed
52
  "
53
ls