본문 바로가기

리눅스

[WIP] GitLab Runner를 실행하고 등록하는 방법

728x90

GitLab Runner를 실행하고 등록하는 방법

GitLab Runner 실행(docker)

docker-compose.yml
version: '3.8'
services:

  gitlab-runner2:
    image: gitlab/gitlab-runner:alpine
    restart: always
    container_name: gitlab-runner2
    hostname: gitlab-runner2
    depends_on:
      - gitlab
    volumes:
      - /usr/share/zoneinfo/Asia/Seoul:/etc/localtime:ro
      - /var/run/docker.sock:/var/run/docker.sock
      - ./gitlab-runner2/config:/etc/gitlab-runner
    networks:
      - jenkins_net

networks:
  jenkins_net:
    name: jenkins_net

Runner 등록

docker exec -it gitlab-runner2 gitlab-runner register \
--non-interactive \
--url "https://gitlab.example.com/" \
--registration-token "glrtszbvS" \
--executor "docker" \
--docker-image docker:latest \
--description "Docker Runner" \
--docker-volumes /var/run/docker.sock:/var/run/docker.sock
--tag-list "docker"

gitlab-ci.yml 테스트 코드

vim .gitlab-ci.yml
image: node:carbon

stages:
  - build
  - test

cache:
  paths:
    - node_modules/

install_dependencies:
  stage: build
  script:
    - npm install
  artifacts:
    paths:
      - node_modules/

test_with_lab:
  stage: test
  script: npm test

GitLab Runner
GitLab Runner

 

참고URL

- gitlab-ci.yml 테스트 코드 : https://github.com/do-community/hello_hapi

- 컨테이너에서 GitLab Runner 실행하기 : https://docs.gitlab.com/runner/install/docker.html

 

728x90