From e189886c5b5d89f8ce51a3c7db6c921dd1064af3 Mon Sep 17 00:00:00 2001 From: Lilian Date: Tue, 4 Feb 2025 18:00:36 -0500 Subject: [PATCH] initial runner deployment --- .gitignore | 2 ++ build-containers.service | 2 +- build-containers.sh | 2 +- config.yml | 6 +++--- forgejo-runner.service | 21 +++++++++++++++++++++ 5 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 .gitignore create mode 100644 forgejo-runner.service diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5762b7b --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# forgejo actions runner registration token +.runner diff --git a/build-containers.service b/build-containers.service index b04579b..5eea565 100644 --- a/build-containers.service +++ b/build-containers.service @@ -3,5 +3,5 @@ Description=Rebuild Forgejo Actions containers [Service] Type=oneshot -ExecStart=/etc/forgejo-runner/build-containers.sh +ExecStart=/etc/forgejo-actions/build-containers.sh Restart=no diff --git a/build-containers.sh b/build-containers.sh index 912f3e6..a6089b4 100755 --- a/build-containers.sh +++ b/build-containers.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -BASEDIR=/etc/forgejo-runner +BASEDIR=/etc/forgejo-actions for container in "$BASEDIR"/Containerfile.*; do base=$(basename "$container") diff --git a/config.yml b/config.yml index 8e0d18f..2bfbdb7 100644 --- a/config.yml +++ b/config.yml @@ -6,7 +6,7 @@ log: runner: # Where to store the registration result. - file: /etc/forgejo-runner/.runner + file: /etc/forgejo-actions/.runner # Execute how many tasks concurrently at the same time. capacity: 1 # Extra environment variables to run jobs. @@ -43,7 +43,7 @@ cache: enabled: true # The directory to store the cache data. # If it's empty, the cache data will be stored in $HOME/.cache/actcache. - dir: "/var/cache/forgejo-actions" + dir: "/mnt/cache/forgejo-actions" # The host of the cache server. # It's not for the address to listen, but the address to connect from job containers. # So 0.0.0.0 is a bad choice, leave it empty to detect automatically. @@ -86,7 +86,7 @@ container: # If "-" or "", an available docker host will automatically be found. # If "automount", an available docker host will automatically be found and mounted in the job container (e.g. /var/run/docker.sock). # Otherwise the specified docker host will be used and an error will be returned if it doesn't work. - docker_host: "/var/run/podman/podman.sock" + docker_host: "" # Pull docker image(s) even if already present force_pull: false # Rebuild local docker image(s) even if already present diff --git a/forgejo-runner.service b/forgejo-runner.service new file mode 100644 index 0000000..16edce9 --- /dev/null +++ b/forgejo-runner.service @@ -0,0 +1,21 @@ +[Unit] +Description=Forgejo Runner +Documentation=https://forgejo.org/docs/latest/admin/actions/ +After=podman.service podman.socket network-online.target +Wants=podman.service + +[Service] +ExecStart=forgejo-runner daemon --config /etc/forgejo-actions/config.yml +ExecReload=/bin/kill -s HUP $MAINPID +Environment="DOCKER_HOST=unix:///run/podman/podman.sock" + +# This user and working directory must already exist +User=runner +WorkingDirectory=/home/runner +Restart=on-failure +TimeoutSec=0 +RestartSec=10 + +[Install] +WantedBy=multi-user.target +