build_testsuite_image.sh 1.28 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
docker rmi ${tag}
10
11
12
13
docker build ${context_dir} \
    -f ${context_dir}/${dockerfile} \
    -m 20G \
    -t ${tag}
Daniel Scheffler's avatar
Daniel Scheffler committed
14
15

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

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}"
30
31
docker exec -it ${gitlab_runner} /bin/bash -c "\
export RUNNER_EXECUTOR=docker && \
Daniel Scheffler's avatar
Daniel Scheffler committed
32
gitlab-ci-multi-runner register -n \
33
34
35
  --non-interactive \
  --executor 'docker' \
  --docker-image '${tag}' \
Daniel Scheffler's avatar
Daniel Scheffler committed
36
  --url 'https://gitext.gfz-potsdam.de/' \
Daniel Scheffler's avatar
Daniel Scheffler committed
37
38
  --registration-token '${token}' \
  --description '${runner_name}' \
39
40
41
42
  --tag-list py_tools_ds_ci_client \
  --run-untagged='true' \
  --locked='false' \
  --access-level='not_protected'"
Daniel Scheffler's avatar
Daniel Scheffler committed
43
ls