Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GITLAB_RUNNER_VERSION=ubuntu-v12.3.0
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM gitlab/gitlab-runner:ubuntu-v10.8.0
ARG VERSION=ubuntu
FROM gitlab/gitlab-runner:${VERSION}

ENV GITLAB_URL ""
ENV REGISTRATION_TOKEN ""
Expand Down
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# gitlab runner
This is an extension of official Gitlab Runner container that uses environment properties to register the container on startup.
This is an extension of the official Gitlab Runner image that uses environment properties to register the runner on container startup and unregister on container shutting down.

### Usage
docker-compose.yml

```
```yml
version: '3.5'

services:
gitlab-runner:
image: flaviostutz/gitlab-runner:ubuntu-v10.8.0
image: flaviostutz/gitlab-runner:ubuntu-v12.3.0
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
Expand All @@ -18,3 +18,10 @@ services:
- NAME=Testing name with space
- TAG_LIST=tag-1,tag-2
```

### Build

The `.env` file contains the version of the official Gitlab Runner image that is used as the base.
To build an image with a different version just change the `.env` file and run `docker-compose build`.

Make sure the Gitlab Runner image version in `.env` file exists in the [gitlab runner image versions](https://hub.docker.com/r/gitlab/gitlab-runner/tags).
9 changes: 6 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
version: '3.5'

# this docker-compose file is used only to build the image. To run, check the docker-compose.yml in the example folder
# this docker-compose file is used only to build the image. To run, check the readme file.
services:
gitlab-runner:
image: flaviostutz/gitlab-runner:ubuntu-v10.8.0
build: .
image: flaviostutz/gitlab-runner:${GITLAB_RUNNER_VERSION}
build:
context: .
args:
- VERSION=${GITLAB_RUNNER_VERSION}
16 changes: 11 additions & 5 deletions startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,21 @@ if [ "$GITLAB_URL" == "" ] || [ "$REGISTRATION_TOKEN" == "" ] || [ "$NAME" == ""
exit 1

elif [ ! -f /registered ]; then
echo "Registering this runner on $GITLAB_URL with token $REGISTRATION_TOKEN and description $NAME.."

if [ "$DOCKER_IMAGE" == "" ]; then
DOCKER_IMAGE="tmaier/docker-compose:latest"
fi

echo "Registering this runner with docker-image $DOCKER_IMAGE on $GITLAB_URL with token $REGISTRATION_TOKEN and description $NAME.."
gitlab-runner --debug register -n \
--url $GITLAB_URL \
--registration-token $REGISTRATION_TOKEN \
--url "$GITLAB_URL" \
--registration-token "$REGISTRATION_TOKEN" \
--executor docker \
--name "$NAME" \
--tag-list "$TAG_LIST" \
--docker-image "tmaier/docker-compose:latest" \
--docker-volumes /var/run/docker.sock:/var/run/docker.sock
--docker-image "$DOCKER_IMAGE" \
--docker-volumes /var/run/docker.sock:/var/run/docker.sock \
--docker-volumes "$DATA_VOLUME"

EXIT_CODE=$?
if [ $EXIT_CODE == 0 ]; then
Expand Down