From 3d1b3a6a3c682f2872f7cbe4a300c007f1bb178d Mon Sep 17 00:00:00 2001 From: Ivan Schaller Date: Fri, 21 Jul 2023 11:25:45 +0200 Subject: [PATCH] update config template, remove unused vars from dockerfile and add custom config file --- README.md | 5 +++++ image/Dockerfile | 22 +------------------- image/config.template.yaml | 12 ++++++++++- image/run_runner.sh | 42 ++++++++++++++++++++------------------ 4 files changed, 39 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index 3ffef22..c19970f 100644 --- a/README.md +++ b/README.md @@ -111,6 +111,11 @@ Example `docker-compose.yml`: The following environment variables can be specified to further configure the service. +#### Runner config file: +Name|Default Value|Description +----|-------------|----------- +EFFECTIVE_CONFIG_FILE|``|Set to a custom config file if the template is not needed. ATTENTION: most environment variables will not work anymore, as they would normally be used for the config file generation. + #### Runner registration: Name|Default Value|Description ----|-------------|----------- diff --git a/image/Dockerfile b/image/Dockerfile index 5cca6cc..f31c2f2 100644 --- a/image/Dockerfile +++ b/image/Dockerfile @@ -185,30 +185,10 @@ ubuntu-20.04:docker://catthehacker/ubuntu:runner-20.04' \ GITEA_RUNNER_UID=1000 \ GITEA_RUNNER_GID=1000 \ # - GITEA_RUNNER_REGISTRATION_FILE='/data/.runner' \ GITEA_RUNNER_REGISTRATION_TIMEOUT=30\ GITEA_RUNNER_REGISTRATION_RETRY_INTERVAL=5s \ # - GITEA_RUNNER_LOG_LEVEL='info' \ - GITEA_RUNNER_MAX_PARALLEL_JOBS=1 \ - GITEA_RUNNER_JOB_TIMEOUT='3h' \ - GITEA_RUNNER_ENV_FILE='/data/.env' \ - GITEA_RUNNER_FETCH_TIMEOUT='5s' \ - GITEA_RUNNER_FETCH_INTERVAL='2s' \ - # - GITEA_INSTANCE_INSECURE='false' \ - # - GITEA_RUNNER_JOB_CONTAINER_DOCKER_HOST="unix:///var/run/docker.sock" \ - GITEA_RUNNER_JOB_CONTAINER_NETWORK='bridge' \ - GITEA_RUNNER_JOB_CONTAINER_OPTIONS='' \ - GITEA_RUNNER_JOB_CONTAINER_PRIVILEGED='false' \ - GITEA_RUNNER_JOB_CONTAINER_WORKDIR_PARENT='/workspace' \ - GITEA_RUNNER_ACTION_CACHE_DIR='/data/cache/actions' \ - # - ACT_CACHE_SERVER_ENABLED='true' \ - ACT_CACHE_SERVER_DIR='/data/cache/server' \ - ACT_CACHE_SERVER_HOST='' \ - ACT_CACHE_SERVER_PORT=0 + GITEA_RUNNER_ACTION_CACHE_DIR='/data/cache/actions' RUN <> "$effective_config_file" - done < $GITEA_RUNNER_CONFIG_TEMPLATE_FILE +# only render template of no custom config file was given +if [[ -z ${EFFECTIVE_CONFIG_FILE} ]]; then + EFFECTIVE_CONFIG_FILE=/tmp/gitea_act_runner_config.yml + rm -f "$EFFECTIVE_CONFIG_FILE" + if [[ ${GITEA_RUNNER_LOG_EFFECTIVE_CONFIG:-false} == "true" ]]; then + log INFO "Effective runner config [$EFFECTIVE_CONFIG_FILE]:" + echo "===========================================================" + while IFS= read -r line; do + line=${line//\"/\\\"} # escape double quotes + line=${line//\`/\\\`} # escape backticks + eval "echo \"$line\"" | tee -a "$EFFECTIVE_CONFIG_FILE" + done < $GITEA_RUNNER_CONFIG_TEMPLATE_FILE + echo "===========================================================" + else + while IFS= read -r line; do + line=${line//\"/\\\"} # escape double quotes + eval "echo \"$line\"" >> "$EFFECTIVE_CONFIG_FILE" + done < $GITEA_RUNNER_CONFIG_TEMPLATE_FILE + fi fi - ################################################# # register act runner if required ################################################# @@ -77,7 +79,7 @@ if [[ ! -s .runner ]]; then --token "$GITEA_RUNNER_REGISTRATION_TOKEN" \ --name "$GITEA_RUNNER_NAME" \ --labels "$GITEA_RUNNER_LABELS" \ - --config "$effective_config_file" \ + --config "$EFFECTIVE_CONFIG_FILE" \ --no-interactive; then break; fi @@ -101,7 +103,7 @@ unset $(env | grep "^GITEA_" | cut -d= -f1) ################################################# case $DOCKER_MODE in dind*) - act_runner daemon --config "$effective_config_file" & + act_runner daemon --config "$EFFECTIVE_CONFIG_FILE" & act_runner_pid=$! function shutdown_act() { @@ -139,6 +141,6 @@ case $DOCKER_MODE in ;; *) - exec act_runner daemon --config "$effective_config_file" + exec act_runner daemon --config "$EFFECTIVE_CONFIG_FILE" ;; esac