LoginSignup
0
0

More than 1 year has passed since last update.

docker-compose で GitHub Enterprise Cloud に接続するセルフホストランナーを簡単に立ち上げる

Posted at

背景

Docker を使ってセルフホストランナーを立ち上げた。
参考: https://qiita.com/Yoshihiro-Hirose/items/650863c3312eaee9770d
複数ランナーを立ち上げるのが手間だったりしたので効率化したい。
公開済みのコンテナイメージと docker-compose を使用する。
また、Github Enterprise Cloud を使っているので enterprise への設定例も載せていく。

実施環境

  • Linux
  • Docker

使用するコンテナイメージ

https://hub.docker.com/r/myoung34/github-runner
上記を参考に github で Personal Access Token を発行しておく

手順

docker-compose.yml ファイルを用意

項目についてはコメントを参照

docker-compose.yml
version: '2.3'

services:
  worker:
    image: myoung34/github-runner:latest
    environment:
      ACCESS_TOKEN: <発行した Personal Access Token>
      RUNNER_NAME_PREFIX: test-runner
      RUNNER_WORKDIR: /tmp/runner/work
      RUNNER_SCOPE: enterprise # enterprise に設定する場合指定
      ENTERPRISE_NAME: <enterprise名> # 契約している enterprise 名
      LABELS: linux,x64,test-runner # 必要に応じてラベルを追加
    mem_limit: 2g # コンテナの最大メモリを指定
    cpus: 2 # CPU の最大使用量を設定
    volumes:
      - '/var/run/docker.sock:/var/run/docker.sock'
      - '/tmp/runner:/tmp/runner'

docker-compose コマンドで立ち上げる

docker-compose up -d --scale worker=4
woker に指定した数だけコンテナが立ち上がる

起動しているか確認

docker stats

ログを確認

docker-compose logs -f --tail="5"

ランナーの停止と起動したコンテナの削除

docker-compose down

github 側の確認

以下 URL を確認
https://github.com/enterprises/<エンタープライズ名>/settings/actions/runners

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0