Commit 89ebe3d5 authored by Kevin Daudt's avatar Kevin Daudt

Merge branch 'add-ci' into 'master'

Improve build code

See merge request !2
parents ac94697f 4458ceba
Pipeline #63 passed with stages
in 1 minute and 26 seconds
- project: 'alpine/infra/gitlab-ci-templates'
ref: master
file: '/docker-image.yml'
......@@ -8,9 +8,9 @@ RUN echo '@edge/testing' >> /e
gitlab-runner@edge/testing \
&& adduser -D -S -h /home/gitlab-runner gitlab-runner
COPY register-runner /usr/local/bin
COPY register-runner entrypoint /usr/local/bin/
VOLUME ["/etc/gitlab-runner", "/home/gitlab-runner"]
ENTRYPOINT ["/usr/bin/gitlab-runner"]
ENTRYPOINT ["/usr/local/bin/entrypoint"]
CMD ["run", "--user=gitlab-runner", "--working-directory=/home/gitlab-runner"]
# gitlab-runner docker image
[![pipeline status](](
This will create a docker image for running a gitlab runner on Alpine Linux on
all the architectures that Alpine Linux supports.
## Starting the runner
To run the container, 1 required and 2 optional volumes need to be attached:
* docker socket (/var/run/docker.sock)
* conf dir (/etc/alpine-runner)
* home dir (/home/gitlab-runner)
For example:
docker run -d \
-v /srv/gitlab-runner/conf:/etc/gitlab-runner \
-v /srv/gitlab-runner/home:/home/gitlab-runner \
-v /var/run/docker.sock:/var/run/docker.sock \
You can execute `./run` to run this command
## Register the runner
There is a `./register-runner` command available in the container to register it.
To execute it, use the following command:
There is a `docker-compose.yml` file included that starts up the runner. The
registration of the runner will be done automatically, but you need to modify
the file to specify some parameters:
docker exec -e ARCH=<arch> -e GITLAB_REGISTER_TOKEN=<token> <container> register-runner
* `<token>` - The gitlab registration token (you can find it in the admin pannel
under runners)
* `<arch>` - The architecture for this runner (used as a description and tag).
* `ARCH` is added as a tag on the runner
* `GITLAB_REGISTER_TOKEN` is a token you can find under `Settings > CI / CD > Runners`
of a specific project or under `Admin > Overview > Runners`.
Then run `docker-compose up -d` and the runner should be running.
version: 3
version: "3"
build: .
image: alpinelinux/gitlab-runner:latest
restart: always
- /srv/gitlab-runner/conf:/etc/gitlab-runner
- /srv/gitlab-runner/home:/home/gitlab-runner
- /var/run/docker.sock:/var/run/docker.sock
ARCH: <arch>
if [ ! -f /etc/gitlab-runner/config.toml ]; then
if [ -z "$GITLAB_REGISTRATION_TOKEN" ] || [ "$GITLAB_REGISTRATION_TOKEN" = '<token>' ]; then
echo "Runner is not configured. Please provide 'GITLAB_REGISTRATION_TOKEN'"
exit 1
register-runner || exit $?
exec gitlab-runner "$@"
echo "-> Registering runner $ARCH"
gitlab-runner register \
--non-interactive \
--url "" \
--registration-token "$GITLAB_REGISTER_TOKEN" \
--registration-token "$GITLAB_REGISTRATION_TOKEN" \
--executor "docker" \
--docker-image alpine:latest \
--description "docker-runner ($ARCH)" \
--tag-list "docker-alpine,$ARCH" \
--run-untagged="true" \
--locked="false" \
--access-level="not_protected" \
--docker-helper-image alpinelinux/gitlab-runner-helper:latest \
--docker-volumes /var/run/docker.sock:/var/run/docker.sock
if [ $status -eq 0 ]; then
echo "-> Registration success"
echo "-> Something went wrong"
exit $status
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