diff --git a/Changelog.md b/Changelog.md index 3fdf98c..e534f78 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,8 @@ # Changelog +**1.1.4-6** + - added docker executor + **1.1.4** - gitlab-ci-multi-runner: upgrade to 1.1.4 diff --git a/README.md b/README.md index cb529be..939170d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![Docker Repository on Quay.io](https://quay.io/repository/sameersbn/gitlab-ci-multi-runner/status "Docker Repository on Quay.io")](https://quay.io/repository/sameersbn/gitlab-ci-multi-runner) -# sameersbn/gitlab-ci-multi-runner:1.1.4-5 +# sameersbn/gitlab-ci-multi-runner:1.1.4-6 - [Introduction](#introduction) - [Contributing](#contributing) @@ -51,7 +51,7 @@ Automated builds of the image are available on [Dockerhub](https://hub.docker.co > **Note**: Builds are also available on [Quay.io](https://quay.io/repository/sameersbn/gitlab-ci-multi-runner) ```bash -docker pull sameersbn/gitlab-ci-multi-runner:1.1.4-5 +docker pull sameersbn/gitlab-ci-multi-runner:1.1.4-6 ``` Alternatively you can build the image yourself. @@ -69,13 +69,21 @@ docker run --name gitlab-ci-multi-runner -d --restart=always \ --volume /srv/docker/gitlab-runner:/home/gitlab_ci_multi_runner/data \ --env='CI_SERVER_URL=http://git.example.com/ci' --env='RUNNER_TOKEN=xxxxxxxxx' \ --env='RUNNER_DESCRIPTION=myrunner' --env='RUNNER_EXECUTOR=shell' \ - sameersbn/gitlab-ci-multi-runner:1.1.4-5 + sameersbn/gitlab-ci-multi-runner:1.1.4-6 ``` *Alternatively, you can use the sample [docker-compose.yml](docker-compose.yml) file to start the container using [Docker Compose](https://docs.docker.com/compose/)* Update the values of `CI_SERVER_URL`, `RUNNER_TOKEN` and `RUNNER_DESCRIPTION` in the above command. If these enviroment variables are not specified, you will be prompted to enter these details interactively on first run. +## Using docker executor + +You can use the docker executor by using `RUNNER_EXECUTOR=docker`. You must provide a docker image to use in `RUNNER_DOCKER_IMAGE` (e.g. docker:latest) + +If `RUNNER_DOCKER_MODE` is set to `socket`, the docker socket is shared between the runner and the build container. If it is not, you must use docker in docker service in your .gitlabci.yml definitions. + +See https://docs.gitlab.com/ce/ci/docker/using_docker_build.html for more info. + ## Command-line arguments You can customize the launch command by specifying arguments to `gitlab-ci-multi-runner` on the `docker run` command. For example the following command prints the help menu of `gitlab-ci-multi-runner` command: @@ -83,7 +91,7 @@ You can customize the launch command by specifying arguments to `gitlab-ci-multi ```bash docker run --name gitlab-ci-multi-runner -it --rm \ --volume /srv/docker/gitlab-runner:/home/gitlab_ci_multi_runner/data \ - sameersbn/gitlab-ci-multi-runner:1.1.4-5 --help + sameersbn/gitlab-ci-multi-runner:1.1.4-6 --help ``` ## Persistence @@ -131,7 +139,7 @@ To upgrade to newer releases: 1. Download the updated Docker image: ```bash - docker pull sameersbn/gitlab-ci-multi-runner:1.1.4-5 + docker pull sameersbn/gitlab-ci-multi-runner:1.1.4-6 ``` 2. Stop the currently running image: @@ -151,7 +159,7 @@ To upgrade to newer releases: ```bash docker run -name gitlab-ci-multi-runner -d \ [OPTIONS] \ - sameersbn/gitlab-ci-multi-runner:1.1.4-5 + sameersbn/gitlab-ci-multi-runner:1.1.4-6 ``` ## Shell Access diff --git a/VERSION b/VERSION index 268838f..fce5864 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.1.4-5 +1.1.4-6 diff --git a/entrypoint.sh b/entrypoint.sh index 3e2c19c..62bfe50 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -50,9 +50,17 @@ grant_access_to_docker_socket() { configure_ci_runner() { if [[ ! -e ${GITLAB_CI_MULTI_RUNNER_DATA_DIR}/config.toml ]]; then if [[ -n ${CI_SERVER_URL} && -n ${RUNNER_TOKEN} && -n ${RUNNER_DESCRIPTION} && -n ${RUNNER_EXECUTOR} ]]; then + if [[ "${RUNNER_EXECUTOR}" == "docker" ]];then + if [[ -n ${RUNNER_DOCKER_IMAGE} ]];then + RUNNER_DOCKER_ARGS="--docker-privileged --docker-image ${RUNNER_DOCKER_IMAGE}" + fi + if [[ "${RUNNER_DOCKER_MODE}" == "socket" ]];then + RUNNER_DOCKER_ARGS="$RUNNER_DOCKER_ARGS --docker-volumes /var/run/docker.sock:/var/run/docker.sock" + fi + fi sudo -HEu ${GITLAB_CI_MULTI_RUNNER_USER} \ gitlab-ci-multi-runner register --config ${GITLAB_CI_MULTI_RUNNER_DATA_DIR}/config.toml \ - -n -u "${CI_SERVER_URL}" -r "${RUNNER_TOKEN}" --name "${RUNNER_DESCRIPTION}" --executor "${RUNNER_EXECUTOR}" + -n -u "${CI_SERVER_URL}" -r "${RUNNER_TOKEN}" --name "${RUNNER_DESCRIPTION}" --executor "${RUNNER_EXECUTOR}" ${RUNNER_DOCKER_ARGS} else sudo -HEu ${GITLAB_CI_MULTI_RUNNER_USER} \ gitlab-ci-multi-runner register --config ${GITLAB_CI_MULTI_RUNNER_DATA_DIR}/config.toml