From ad6de5ba837c94990067b9355d783d74de723f52 Mon Sep 17 00:00:00 2001 From: Hana Date: Tue, 9 Jun 2026 14:59:10 +0900 Subject: [PATCH] Add Gitea runner configuration --- .gitignore | 2 ++ README.md | 24 ++++++++++++++++++++++++ ops/gitea-runner/.env.example | 4 ++++ ops/gitea-runner/docker-compose.yml | 13 +++++++++++++ scripts/runner-down.sh | 7 +++++++ scripts/runner-logs.sh | 7 +++++++ scripts/runner-up.sh | 21 +++++++++++++++++++++ 7 files changed, 78 insertions(+) create mode 100644 ops/gitea-runner/.env.example create mode 100644 ops/gitea-runner/docker-compose.yml create mode 100755 scripts/runner-down.sh create mode 100755 scripts/runner-logs.sh create mode 100755 scripts/runner-up.sh diff --git a/.gitignore b/.gitignore index aef89ee..dc96163 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ /target/ .env .openstock/ +ops/gitea-runner/.env +ops/gitea-runner/data/ diff --git a/README.md b/README.md index ecf4382..44555e6 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,30 @@ git push origin main v0.1.0 | act runner | `ubuntu-latest` job을 실행할 runner가 등록되어 있어야 합니다. | | release permission | workflow의 `${{ secrets.GITEA_TOKEN }}`가 release 생성/asset 업로드 권한을 가져야 합니다. | +### Runner + +Docker 기반 Gitea act runner 구성은 `ops/gitea-runner`에 있습니다. 등록 토큰은 Gitea repository settings의 Actions runner 화면에서 발급받아 로컬 `.env`에만 저장합니다. + +```bash +cp ops/gitea-runner/.env.example ops/gitea-runner/.env +vi ops/gitea-runner/.env +./scripts/runner-up.sh +``` + +러너 상태와 로그: + +```bash +./scripts/runner-logs.sh +``` + +중지: + +```bash +./scripts/runner-down.sh +``` + +runner는 `/var/run/docker.sock`을 mount하므로 이 머신의 Docker 권한을 가진 신뢰 가능한 저장소에만 연결해야 합니다. `ops/gitea-runner/.env`와 `ops/gitea-runner/data/`는 registration token과 runner state를 포함할 수 있어 git에서 제외합니다. + ## Architecture | Layer | Path | Role | diff --git a/ops/gitea-runner/.env.example b/ops/gitea-runner/.env.example new file mode 100644 index 0000000..b3f2f49 --- /dev/null +++ b/ops/gitea-runner/.env.example @@ -0,0 +1,4 @@ +GITEA_INSTANCE_URL=https://git.hananakick.cc +GITEA_RUNNER_REGISTRATION_TOKEN=replace-with-repository-runner-token +GITEA_RUNNER_NAME=openstock-runner +GITEA_RUNNER_LABELS=ubuntu-latest:docker://docker.gitea.com/runner-images:ubuntu-latest diff --git a/ops/gitea-runner/docker-compose.yml b/ops/gitea-runner/docker-compose.yml new file mode 100644 index 0000000..44953b6 --- /dev/null +++ b/ops/gitea-runner/docker-compose.yml @@ -0,0 +1,13 @@ +services: + openstock-runner: + image: docker.io/gitea/act_runner:latest + container_name: openstock-gitea-runner + restart: unless-stopped + environment: + GITEA_INSTANCE_URL: ${GITEA_INSTANCE_URL} + GITEA_RUNNER_REGISTRATION_TOKEN: ${GITEA_RUNNER_REGISTRATION_TOKEN} + GITEA_RUNNER_NAME: ${GITEA_RUNNER_NAME:-openstock-runner} + GITEA_RUNNER_LABELS: ${GITEA_RUNNER_LABELS:-ubuntu-latest:docker://docker.gitea.com/runner-images:ubuntu-latest} + volumes: + - ./data:/data + - /var/run/docker.sock:/var/run/docker.sock diff --git a/scripts/runner-down.sh b/scripts/runner-down.sh new file mode 100755 index 0000000..7511d52 --- /dev/null +++ b/scripts/runner-down.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env sh +set -eu + +RUNNER_DIR="$(CDPATH= cd -- "$(dirname -- "$0")/../ops/gitea-runner" && pwd)" + +cd "$RUNNER_DIR" +docker compose down diff --git a/scripts/runner-logs.sh b/scripts/runner-logs.sh new file mode 100755 index 0000000..4409111 --- /dev/null +++ b/scripts/runner-logs.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env sh +set -eu + +RUNNER_DIR="$(CDPATH= cd -- "$(dirname -- "$0")/../ops/gitea-runner" && pwd)" + +cd "$RUNNER_DIR" +docker compose logs -f openstock-runner diff --git a/scripts/runner-up.sh b/scripts/runner-up.sh new file mode 100755 index 0000000..ef80cec --- /dev/null +++ b/scripts/runner-up.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env sh +set -eu + +RUNNER_DIR="$(CDPATH= cd -- "$(dirname -- "$0")/../ops/gitea-runner" && pwd)" +ENV_FILE="$RUNNER_DIR/.env" + +if [ ! -f "$ENV_FILE" ]; then + cp "$RUNNER_DIR/.env.example" "$ENV_FILE" + echo "created: $ENV_FILE" >&2 + echo "edit GITEA_RUNNER_REGISTRATION_TOKEN before starting the runner" >&2 + exit 1 +fi + +if grep -q 'replace-with-repository-runner-token' "$ENV_FILE"; then + echo "missing GITEA_RUNNER_REGISTRATION_TOKEN in $ENV_FILE" >&2 + exit 1 +fi + +cd "$RUNNER_DIR" +docker compose up -d +docker compose ps