본문 바로가기

리눅스

[리눅스] gitlab runner 설치 및 실행하기

728x90

gitlab runner 설치 및 실행하기

gitlab runner 설치

$ mkdir gitlab-runner

$ cd gitlab-runner

docker-compose.yml 편집

cat <<EOF > docker-compose.yml
version: '3.8'
services:

  gitlab-runner:
    image: gitlab/gitlab-runner:latest
    restart: unless-stopped
    container_name: gitlab-runner
    hostname: gitlab-runner
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /var/run/docker.sock:/var/run/docker.sock
      - ./config:/etc/gitlab-runner
EOF

gitlab-runner 컨테이너 실행

docker-compose up -d
$ docker-compose up -d
[+] Running 4/4
 ⠿ gitlab-runner Pulled                             64.9s
   ⠿ 4d32b49e2995 Pull complete                     12.3s
   ⠿ 617ef4a56299 Pull complete                     58.4s
   ⠿ 797d26c5d28d Pull complete                     58.8s
[+] Running 2/2
 ⠿ Network docker-gitlab-runner_default  Created     0.4s
 ⠿ Container gitlab-runner               Started    13.6s
$ docker-compose ps
NAME           COMMAND                  SERVICE          STATUS     PORTS
gitlab-runner  "/usr/bin/dumb-init …"   gitlab-runner    running

gitlab runner 등록

프로젝트 > 설정 > CI/CD > Runners 섹션

docker-compose exec gitlab-runner bash
gitlab-runner register
$ docker-compose exec gitlab-runner bash
root@acd54bbc5de3:/$ gitlab-runner register
Runtime platform        arch=amd64 os=linux pid=25 revision=bd40e3da version=14.9.1
Running in system-mode.

Enter the GitLab instance URL (for example, https://gitlab.com/):
https://gitlab.scbyun.com/
Enter the registration token:
GxxxxxxxxxxxxxxxxxxxxxxxxxxxN
Enter a description for the runner:
[acd54bbc5de3]: runner01
Enter tags for the runner (comma-separated):
runner
Registering runner... succeeded        runner=GR134894
Enter an executor: custom, docker, docker-ssh, parallels, kubernetes, shell, ssh, virtualbox, docker+machine, docker-ssh+machine:
docker
Enter the default Docker image (for example, ruby:2.7):
alpine:latest
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
cat config/config.toml
$ cat config/config.toml
concurrent = 1
check_interval = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "runner01"
  url = "https://gitlab.scbyun.com/"
  token = "bRCWvXqMVcR6KWUFp-Sr"
  executor = "docker"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
    [runners.cache.azure]
  [runners.docker]
    tls_verify = false
    image = "alpine:latest"
    privileged = false
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/cache"]
    shm_size = 0

runner 편집

728x90