Skip to content

Commit

Permalink
Merge pull request #2 from s4s0l/CONFIGURE_MOUNT_POINTS
Browse files Browse the repository at this point in the history
Bunch of changes that will allow to specify docker volumes via env vars
  • Loading branch information
FlakM authored Feb 6, 2018
2 parents 79f9661 + d7b2742 commit cb6f24e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
31 changes: 19 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ docker run -d -e "CI_SERVER_URL=https://gitlab.com/" \
-e REGISTRATION_TOKEN="$REGISTRATION_TOKEN" \
-e ADMIN_TOKEN="$ADMIN_TOKEN" \
-e PROJECTS_TO_REGISTER="$PROJECTS_TO_REGISTER" \
-e LOCKED_MODE="false" \
-e REGISTER_LOCKED="false" \
--name gitlab-runner-testing \
-v /var/run/docker.sock:/var/run/docker.sock \
flakm/gitlab-runner-auto-register:latest
Expand All @@ -63,17 +63,24 @@ docker exec -i gitlab-runner gitlab-runner register

# Environment Variables

| Property | Description | Default value | Required |
| -------------------- | -----------------------------------------------------------------------------------------------------------------------| ------------------------------- | ------------- |
|`CI_SERVER_URL` | url of gitlab instance | | true |
|`REGISTRATION_TOKEN` | /settings/ci_cd tab of your project | | true |
|`PRIVILIGED_MODE` | should you need to run in priviliged mode set to true (otherwise defaults to false) | false | false |
|`LOCKED_MODE` | should this runner be locked to this project or not | true | false |
|`ADMIN_TOKEN` | access token with admin privilages (if specified runner will be registered for projects`PROJECTS_TO_REGISTER`) | | false |
|`PROJECTS_TO_REGISTER` | project ids seperated by `;` | | false |
|`CUSTOM_RUNNER_NAME` | runner's description | `$HOSTNAME` | false |

For more information about the the environment variables execute `gitlab-runner register --help` inside docker
| Property | Description | Default value | Required |
| -------------------- | -----------------------------------------------------------------------------------------------------------------------------------------| ------------------------------- | ------------- |
|`CI_SERVER_URL` | url of gitlab instance | | true |
|`REGISTRATION_TOKEN` | /settings/ci_cd tab of your project | | true |
|`DOCKER_PRIVILEGED` | should you need to run in priviliged mode set to true (otherwise defaults to false) | false | false |
|`REGISTER_LOCKED` | should this runner be locked to this project or not | true | false |
|`ADMIN_TOKEN` | access token with admin privilages (if specified runner will be registered for projects`PROJECTS_TO_REGISTER`) | | false |
|`PROJECTS_TO_REGISTER` | project ids seperated by `;` | | false |
|`CUSTOM_RUNNER_NAME` | runner's description | `$HOSTNAME` | false |
|`DOCKER_VOLUMES` | volume mounted by this runner | | false |
|`DOCKER_IMAGE` | docker image to use | docker:18.01.0-ce | true |
|`REGISTER_EXTRA_ARGS` | can contain extra arguments for running `gitlab-runner register`. <br>Can be used for example to specify multiple --docker-volumes args | | false |

For more information about the the environment variables execute:
```
docker run --rm --entrypoint "/usr/bin/gitlab-runner" flakm/gitlab-runner-auto-register:latest register --help
```



# Inspiration
Expand Down
14 changes: 5 additions & 9 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,15 @@ if [ -z "$CI_SERVER_URL" ]; then
CI_SERVER_URL="https://gitlab.com/"
fi

if [ -z "$DOCKER_IMAGE" ]; then
export DOCKER_IMAGE=docker:18.01.0-ce
fi

if [ -z "$REGISTRATION_TOKEN" ]; then
echo "ERROR: Env REGISTRATION_TOKEN not set!"
exit 1
fi

if [ "$PRIVILIGED_MODE" != "true" ]; then
PRIVILIGED_MODE="false"
fi

if [ "$LOCKED_MODE" != "true" ]; then
LOCKED_MODE="true"
fi

if [ "$ADMIN_TOKEN" != "" ]; then
REGISTER_OTHER_PROJECTS="true"
PROJECTS_STRING="$PROJECTS_TO_REGISTER"
Expand Down Expand Up @@ -55,7 +51,7 @@ trap "gitlab-runner stop" SIGTERM
echo "===> Running gitlab-runner register..."
export REGISTER_NON_INTERACTIVE=true

gitlab-runner register --executor=docker --locked=$LOCKED_MODE --docker-image=docker:latest --docker-privileged=$PRIVILIGED_MODE --docker-volumes=/var/run/docker.sock:/var/run/docker.sock
gitlab-runner register --executor=docker $REGISTER_EXTRA_ARGS
if [ $? -gt 0 ]; then
echo "===> ERROR: Registration failed!"
exit 1
Expand Down

0 comments on commit cb6f24e

Please sign in to comment.