Gitlab runner in Docker container with gradle environment

In this article Gitlab runner in Docker container you can see installation procedure for gitlab runner in docker.

After runner required lot of configuration.

For optimize this procedure we prepared docker image based on official gitlab runner docker image with minor improvements:

  • added Oracle Java 8
  • added gradle build system
  • added nodejs v6

Project home: https://github.com/startext/gitlab-runner-gradle.

Docker container creation

Create container with configuration:

$ docker volume create --name gitlab-runner-config

Create gitlab runner:

$ docker run -d --name gitlab-runner-gradle --restart always \
  -v gitlab-runner-config:/etc/gitlab-runner \
  startext/gitlab-runner-gradle:latest

Register the runner:

$ docker exec -it gitlab-runner-gradle gitlab-runner register \
  --non-interactive \
  --url "https://git.startext.ru:5000/ci" \
  --registration-token "TOKEN_HERE" \
  --name "runner-name" \
  --executor "shell" \
  --tag-list "java,gradle,nodejs"
INFO[0000] TN4Lx9Wp Registering runner... succeeded
INFO[0000] Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!

Check version

$ docker exec -ti gitlab-runner-gradle gitlab-runner -v

Update container

Pull the latest version:

$ docker pull startext/gitlab-runner-gradle

Stop and remove the existing container:

$ docker stop gitlab-runner-gradle && docker rm gitlab-runner-gradle

Create the container as we did it before:

$ docker run -d --name gitlab-runner-gradle --restart always \
  -v gitlab-runner-config:/etc/gitlab-runner \
  startext/gitlab-runner-gradle:latest