Commit f56c605a authored by Cody Mize's avatar Cody Mize

Run project from docker image

parent 8fa25c91
# We use the onbuild version of library/golang,
# (https://github.com/docker-library/golang/blob/master/1.4/onbuild/Dockerfile)
FROM golang:onbuild
# Set working directory to /data
#
# this is where the config.toml will be sourced,
# you can mount your own custom data directory at /data
WORKDIR /data
VOLUME /data
# init sets up the environment and launches gitlab-ci-multi-runner
ENTRYPOINT ["/go/src/app/packaging/docker/init"]
CMD ["run"]
......@@ -24,7 +24,7 @@ This project was made as Go learning opportunity. The initial release was create
- connecting to remote SSH server
* Is written in Go and distributed as single binary without any other requirements
* Supports Bash, Windows Batch and Windows PowerShell
* Works on Ubuntu, Debian, OS X and Windows (should also work on other Linux distributions)
* Works on Ubuntu, Debian, OS X and Windows (and anywhere you can run Docker)
* Allows to customize job running environment
* Automatic configuration reload without restart
* Easy to use setup with support for docker, docker-ssh, parallels or ssh running environments
......@@ -147,6 +147,80 @@ This project was made as Go learning opportunity. The initial release was create
@reboot gitlab-ci-multi-runner run &>gitlab-ci-multi-runner.log
```
### Docker image installation and configuration (run gitlab-ci-multi-runner in a container)
1. Pull the image (optional):
```bash
$ docker pull ayufan/gitlab-ci-multi-runner:latest
```
1. Start the container:
We need to mount a data volume into our gitlab-ci-multi-runner container to be used for configs and other resources:
```bash
$ docker run -d --name multi-runner --restart always \
-v /PATH/TO/DATA/FOLDER:/data \
ayufan/gitlab-ci-multi-runner:latest
```
OR you can use a data container to mount you custom data volume:
```bash
$ docker run -d --name multi-runner-data -v /data \
busybox:latest /bin/true
$ docker run -d --name multi-runner --restart always \
--volumes-from multi-runner-data \
ayufan/gitlab-ci-multi-runner:latest
```
If you are planning on using Docker as the method of spawing runners you'll need to mount your docker socket like so:
```bash
$ docker run -d --name multi-runner --restart always \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /PATH/TO/DATA/FOLDER:/data \
ayufan/gitlab-ci-multi-runner:latest
```
1. Setup the runner:
```bash
$ docker exec -it multi-runner gitlab-ci-multi-runner setup
Please enter the gitlab-ci coordinator URL (e.g. http://gitlab-ci.org:3000/ )
https://ci.gitlab.org/
Please enter the gitlab-ci token for this runner
xxx
Please enter the gitlab-ci description for this runner
my-runner
INFO[0034] fcf5c619 Registering runner... succeeded
Please enter the executor: shell, docker, docker-ssh, ssh?
docker
Please enter the Docker image (eg. ruby:2.1):
ruby:2.1
INFO[0037] Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
```
1. Runner should be started already and you are ready to build your projects!
#### Update
1. Pull the latest version:
```bash
$ docker pull ayufan/gitlab-ci-multi-runner:latest
```
1. Stop and remove the existing container:
```bash
$ docker stop multi-runner && docker rm multi-runner
```
1. Start the container as you did originally:
```bash
$ docker run -d --name multi-runner --restart always \
--volumes-from multi-runner-data \
-v /var/run/docker.sock:/var/run/docker.sock \
ayufan/gitlab-ci-multi-runner:latest
```
**note**: you need to use the same method for mounting you data volume as you did originally (`-v /PATH/TO/DATA/FOLDER:/data` or `--volumes-from multi-runner-data`)
### Extra projects?
If you want to add another project, token or image simply re-run setup. *You don't have to re-run the runner. He will automatically reload configuration once it changes.*
......
#!/bin/bash
# gitlab-ci-multi-runner data directory
DATA_DIR="/data"
CONFIG_FILE=${CONFIG_FILE:-$DATA_DIR/config.toml}
# custom certificate authority path
CA_CERTIFICATES_PATH=${CA_CERTIFICATES_PATH:-$DATA_DIR/certs/ca.crt}
LOCAL_CA_PATH="/usr/local/share/ca-certificates/ca.crt"
update_ca () {
echo "Updating CA certificates..."
cp "${CA_CERTIFICATES_PATH}" "${LOCAL_CA_PATH}"
update-ca-certificates --fresh >/dev/null
}
if [ -f "${CA_CERTIFICATES_PATH}" ]; then
# update the ca if the custom ca is different than the current
cmp --silent "${CA_CERTIFICATES_PATH}" "${LOCAL_CA_PATH}" \
|| update_ca
fi
if [ ! -f "${CONFIG_FILE}" ]; then
# create config file if it does not exist
mkdir -p $(dirname "${CONFIG_FILE}") && touch "${CONFIG_FILE}"
fi
# launch gitlab-ci-multi-runner passing all arguments
exec gitlab-ci-multi-runner "[email protected]"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment