Self-Hosted Runner for Github Actions

2024. 2. 21. 14:00Env/Tools

    목차
반응형

ref.

https://docs.github.com/en/enterprise-server@3.5/actions/hosting-your-own-runners/about-self-hosted-runners

https://docs.docker.com/engine/install/centos/

[Install Docker Engine on CentOS

Learn how to install Docker Engine on CentOS. These instructions cover the different installation methods, how to uninstall, and next steps.

docs.docker.com](https://docs.docker.com/engine/install/centos/)

 

Setting up Docker Environment

Docker 실행 환경을 구성

  • 패키지 저장소 추가
  • sudo yum install -y yum-utils sudo yum-config-manager \ --add-repo \ https://download.docker.com/linux/centos/docker-ce.repo
  • 패키지 설치
  • sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
  • Mirror Registry 등록
  • cat << EOF > /etc/docker/daemon.json { "registry-mirrors": ["https://docker-hub-mirror.xxx.com"] } EOF
  • Docker 시작
  • sudo systemctl start docker
  • systemd 서비스 등록
  • sudo systemctl enable docker.service sudo systemctl enable containerd.service
  • docker 사용 group 추가
    user1을 docker를 사용할 수 있는 group 에 추가
  • sudo /sbin/usermod -aG docker user1 sudo /sbin/usermod -aG docker www sudo systemctl restart docker

 

Adding up a Self-Hosted Runner

Linux x64 환경에서 실행할 Runner 인스턴스를 추가

  • github project > Settings > Actions > New Runner에서 사용할 Runner 플랫폼을 선택
  • 필요 파일 설치
  • # Create a folder $ mkdir actions-runner && cd actions-runner # Download the latest runner package $ curl -o actions-runner-osx-x64-2.289.4.tar.gz -L -H 'Authorization: Bearer ab70ezabOk...wbOcapz' https://git.xxx.com/_services/pipelines/_apis/distributedtask/packagedownload/agent/osx-x64/2.289.4 # Optional: Validate the hash $ echo "6466bc9573f7f8...230e29a775ae actions-runner-osx-x64-2.289.4.tar.gz" | shasum -a 256 -c # Extract the installer $ tar xzf ./actions-runner-osx-x64-2.289.4.tar.gz
  • 파일 실행
  • # Create the runner and start the configuration experience $ ./config.sh --url https://git.xxx.com/repo --token BADVEHKFDHJFHDJKHSDFDEJHKFEJKI # Last step, run it! $ ./run.sh
  • Runner 서비스 등록
  • $ sudo sh ./svc.sh install $ sudo sh ./svc.sh start

위 과정 수행 후 github의 Runners 목록에서 추가된 인스턴스를 확인할 수 있습니다.

Change The Docker Data Directory

Runner 인스턴스 수행을 위해 볼륨을 추가

  • 디스크 부착 후 용량 확인
  • $ df -h Filesystem Size Used Avail Use% Mounted on ... /dev/vdc1 500G 2.7G 498G 1% /mnt/docker-root
  • /etc/fstab 파일 안에 디스크 마운트 옵션 지정
  • # # /etc/fstab # Created by os_image_builder # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # UUID=57436312-ckz7-3b4e-8d4b-92d84dea0a2k / xfs defaults,noatime,nodev,inode64 0 0 /home1 /home none defaults,bind 0 0 /dev/vdb none swap sw,comment=cloudconfig 0 0 UUID=125af9fb-24d9-3984-b89b-6534321kbf77 /mnt/docker-root xfs defaults,noatime,nodev,inode64 0 0
  • Docker 설정 변경 (/etc/docker/daemon.json)
  • { "registry-mirrors": ["https://docker-hub-mirror.xxx.com"], "data-root": "/mnt/docker-root" }
반응형