From e599a9210b909518b57e63e650fff4484abcc533 Mon Sep 17 00:00:00 2001 From: casjay Date: Sun, 11 Aug 2024 14:26:53 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=97=83=EF=B8=8F=20Committing=20everything?= =?UTF-8?q?=20that=20changed=20=F0=9F=97=83=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit rootfs/tmp/etc/act_runner/multi.yaml rootfs/usr/local/etc/docker/init.d/zz-act_runner.sh --- rootfs/tmp/etc/act_runner/multi.yaml | 66 +++++++++++++++++++ .../local/etc/docker/init.d/zz-act_runner.sh | 18 +++-- 2 files changed, 80 insertions(+), 4 deletions(-) create mode 100644 rootfs/tmp/etc/act_runner/multi.yaml diff --git a/rootfs/tmp/etc/act_runner/multi.yaml b/rootfs/tmp/etc/act_runner/multi.yaml new file mode 100644 index 0000000..bb2c3b8 --- /dev/null +++ b/rootfs/tmp/etc/act_runner/multi.yaml @@ -0,0 +1,66 @@ +# Config for act_runner daemon +log: + # The level of logging, can be trace, debug, info, warn, error, fatal + level: info + +host: + # The parent directory of a job's working directory. + workdir_parent: '/tmp/act_runner' + +runner: + # Where to store the registration result. + file: REPLACE_RUNNER_HOME/runners + # Execute how many tasks concurrently at the same time. + capacity: 1 + # Extra environment variables to run jobs. + envs: + A_TEST_ENV_NAME_1: a_test_env_value_1 + # Extra environment variables to run jobs from a file. + env_file: .env + # The timeout for a job to be finished. + timeout: 3h + # Whether skip verifying the TLS certificate of the Gitea instance. + insecure: true + # The timeout for fetching the job from the Gitea instance. + fetch_timeout: 5s + # The interval for fetching the job from the Gitea instance. + fetch_interval: 2s + # The labels of a runner are used to determine which jobs the runner can run, and how to run them. + labels: + #- 'macos:docker:dockurr/macos' + #- 'windows:docker:dockurr/windows' + #- 'linux:docker:casjaysdev/almalinux' + #- 'alma:docker:casjaysdev/almalinux' + #- 'alpine:docker:casjaysdev/alpine' + #- 'debian:docker:casjaysdev/debian' + #- 'arch:docker:casjaysdev/archlinux' + #- 'node:docker://node:latest' + #- 'node14:docker://node:14' + #- 'node16:docker://node:16' + #- 'node18:docker://node:18' + #- 'node20:docker://node:20' + #- 'node20:docker://node:20' + #- 'python3:docker://python:latest' + #- 'php7:docker://php:7-fpm' + #- 'php8:docker://php:8-fpm' + #- 'php:docker://php:8.4-rc-fpm-alpine3.20' + #- 'alpine:docker://casjaysdev/alpine:latest' + #- 'almalinux:docker://casjaysdev/almalinux:latest' + #- 'debian:docker://casjaysdev/debian:latest' + #- 'ubuntu:docker://casjaysdev/ubuntu:latest' + #- 'linux:host,ubuntu-latest:docker://catthehacker/ubuntu:full-latest' + +container: + # Specifies the network to which the container will connect. + network: 'bridge' + # Whether to use privileged mode or not when launching task containers (privileged mode is required for Docker-in-Docker). + privileged: true + # And other options to be used when the container is started (eg, --add-host=my.gitea.url:host-gateway). + options: + # The parent directory of a job's working directory. + workdir_parent: '/tmp/act_runner/volumes' + # Volumes (including bind mounts) can be mounted to containers. Glob syntax is supported, see https://github.com/gobwas/glob + valid_volumes: + - '**' + # overrides the docker client host with the specified one. + docker_host: '' diff --git a/rootfs/usr/local/etc/docker/init.d/zz-act_runner.sh b/rootfs/usr/local/etc/docker/init.d/zz-act_runner.sh index 1158cca..57696ff 100755 --- a/rootfs/usr/local/etc/docker/init.d/zz-act_runner.sh +++ b/rootfs/usr/local/etc/docker/init.d/zz-act_runner.sh @@ -212,6 +212,7 @@ RUNNER_NAME="sample" RUNNER_LABELS="$RUNNER_LABELS" RUNNER_AUTH_TOKEN="${RUNNER_AUTH_TOKEN:-$SYS_AUTH_TOKEN}" RUNNER_HOSTNAME="${INSTANCE_HOSTNAME:-http://127.0.0.1:8000}" +CONTAINER_IP4_ADDRESS="${INSTANCE_HOSTNAME}" EOF fi if [ ! -f "$CONF_DIR/.runner" ]; then @@ -222,16 +223,20 @@ EOF cat <"$CONF_DIR/reg/default.reg" # Settings for the default gitea runner RUNNER_NAME="gitea" +RUNNER_HOME="$CONF_DIR/multi/$RUNNER_NAME" RUNNER_LABELS="$RUNNER_LABELS" RUNNER_AUTH_TOKEN="${RUNNER_AUTH_TOKEN:-$SYS_AUTH_TOKEN}" RUNNER_HOSTNAME="${INSTANCE_HOSTNAME:-http://127.0.0.1:8000}" +CONTAINER_IP4_ADDRESS="${CONTAINER_IP4_ADDRESS}" EOF cat <"$CONF_DIR/reg/runner.reg" -# Settings for the default gitea runner -RUNNER_NAME="runner" +# Settings for the default local runner +RUNNER_NAME="local" +RUNNER_HOME="$CONF_DIR/multi/$RUNNER_NAME" RUNNER_LABELS="$RUNNER_LABELS" RUNNER_AUTH_TOKEN="${RUNNER_AUTH_TOKEN:-$SYS_AUTH_TOKEN}" RUNNER_HOSTNAME="${INSTANCE_HOSTNAME:-http://127.0.0.1:8000}" +CONTAINER_IP4_ADDRESS="${CONTAINER_IP4_ADDRESS}" EOF fi if [ ! -f "$CONF_DIR/runners" ]; then @@ -241,6 +246,7 @@ EOF while :; do [ -f "$runner" ] && . "$runner" [ -f "$RUN_DIR/act_runner.$RUNNER_NAME.pid" ] && break + RUNNER_HOME="${RUNNER_HOME:-$CONF_DIR/multi/$RUNNER_NAME}" if [ -z "$RUNNER_AUTH_TOKEN" ]; then [ -f "$CONF_DIR/tokens/system" ] && RUNNER_AUTH_TOKEN="$(<"$CONF_DIR/tokens/system")" [ -f "$CONF_DIR/tokens/$RUNNER_NAME" ] && RUNNER_AUTH_TOKEN="$(<"$CONF_DIR/tokens/$RUNNER_NAME")" || { [ -n "$SYS_AUTH_TOKEN" ] && echo "$SYS_AUTH_TOKEN" >"$CONF_DIR/tokens/$RUNNER_NAME"; } @@ -251,11 +257,15 @@ EOF sleep 120 else echo "RUNNER_AUTH_TOKEN has been set: trying to register $RUNNER_NAME" - act_runner register --config "$CONF_DIR/daemon.yaml" --labels "$RUNNER_LABELS" --name "$RUNNER_NAME" --instance "http://$CONTAINER_IP4_ADDRESS:8000" --token "$RUNNER_AUTH_TOKEN" --no-interactive && exitStatus=0 || exitStatus=1 + act_runner register --config "$RUNNER_HOME/$RUNNER_NAME.yaml" --labels "$RUNNER_LABELS" --name "$RUNNER_NAME" --instance "http://$CONTAINER_IP4_ADDRESS:8000" --token "$RUNNER_AUTH_TOKEN" --no-interactive && exitStatus=0 || exitStatus=1 echo "$!" >"$RUN_DIR/act_runner.$RUNNER_NAME.pid" if [ $exitStatus -eq 0 ]; then exitStatus=0 - chown -Rf "$SERVICE_USER":"$SERVICE_GROUP" "$CONF_DIR" "$ETC_DIR" + mv -fv "$runner" "$RUNNER_HOME/$RUNNER_NAME.reg" + cp -Rf "$CONF_DIR/multi.yaml" "$RUNNER_HOME/$RUNNER_NAME.yaml" + __replace "REPLACE_RUNNER_HOME" "$RUNNER_HOME" "$RUNNER_HOME/$RUNNER_NAME.yaml" + chown -Rf "$SERVICE_USER":"$SERVICE_GROUP" "$RUNNER_HOME" + act_runner daemon --config $RUNNER_HOME/$RUNNER_NAME.yaml break else [ -f "$RUN_DIR/act_runner.$RUNNER_NAME.pid" ] && rm -f "$RUN_DIR/act_runner.$RUNNER_NAME.pid"