Skip to main content

Gitlab Runner

Dockerfile

FROM debian:stable-slim

RUN apt-get update && \
    apt-get install -y curl

RUN curl -fsSL get.docker.com | sh

RUN curl -LJO "https://gitlab-runner-downloads.s3.amazonaws.com/latest/deb/gitlab-runner_amd64.deb"

RUN apt install -fy ./gitlab-runner_amd64.deb

RUN apt-get clean

CMD ["gitlab-runner", "run"]


docker-compose.yaml

version: '3'
services:
  gitlab-runner:
    image: 'registry.gitlab.com/eagleprojectsit/gitlab-runner-debian:latest'
    container_name: 'runner1'
    command: 'tail -f /dev/null'
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./config:/etc/gitlab-runner
    restart: unless-stopped

Instructions

  1. Run docker compose file as is docker compose up -d
  2. execute docker exec -it runner1 /bin/bash
  3. once in the container shell gitlab-runner register (select shell when asked) ff807169232b695ad650a449e51e2d77.png eaed7b43fd0fbdaaee21e811931ffefe.png
  4. fill the data provided by gitlab (settings>ci_cd>New project runner) 1040d884e6d494c7906cf4ec35391c6c.png

folow only step 1 ab9e9bf52d3741161b7ca32323f3225c.png

  1. exit container shell exit

  2. stop the docker compose docker compose down

  3. edit the docker compose commenting the line command as following nano docker-compose.yaml

    #command: 'tail -f /dev/null'
  1. start the docker again docker compose up -d

!!!note edit image and container_name as you prefer !!!