From ed2ae5f47b15365e59f88ff7ae4711a7c835cee9 Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Thu, 26 Oct 2023 19:52:49 -0500 Subject: [PATCH] Split act-runner into its own pod. --- .../Dockerfile.task-executor | 0 .../config/act-runner-config.yml | 2 +- act-runner/docker-compose.yml | 23 +++++++++++++++++++ act-runner/post_start.sh | 4 ++++ act-runner/pre_start.sh | 4 ++++ .../stack/deploy/commands.py | 3 ++- gitea/README.md | 2 +- gitea/docker-compose.yml | 22 ------------------ 8 files changed, 35 insertions(+), 25 deletions(-) rename {gitea => act-runner}/Dockerfile.task-executor (100%) rename {gitea => act-runner}/config/act-runner-config.yml (98%) create mode 100644 act-runner/docker-compose.yml create mode 100755 act-runner/post_start.sh create mode 100755 act-runner/pre_start.sh rename {gitea => act-runner}/stack/deploy/commands.py (83%) diff --git a/gitea/Dockerfile.task-executor b/act-runner/Dockerfile.task-executor similarity index 100% rename from gitea/Dockerfile.task-executor rename to act-runner/Dockerfile.task-executor diff --git a/gitea/config/act-runner-config.yml b/act-runner/config/act-runner-config.yml similarity index 98% rename from gitea/config/act-runner-config.yml rename to act-runner/config/act-runner-config.yml index f21e435..6c55008 100644 --- a/gitea/config/act-runner-config.yml +++ b/act-runner/config/act-runner-config.yml @@ -45,4 +45,4 @@ container: # 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: --add-host=gitea.local:host-gateway --volume "/var/lib/docker" + options: --add-host=gitea.local:host-gateway --volume "/var/lib/docker" --volume "/data:/data:ro" diff --git a/act-runner/docker-compose.yml b/act-runner/docker-compose.yml new file mode 100644 index 0000000..e5370d1 --- /dev/null +++ b/act-runner/docker-compose.yml @@ -0,0 +1,23 @@ + +services: + runner: + image: cerc/act-runner:local + restart: always + environment: + - CONFIG_FILE=/config/act-runner-config.yml + # Note: eMdEwIzSo87nBh0UFWZlbp308j6TNWr3WhWxQqIc is a static token we use for convenience in stand-alone deployments. Not secure, obviously. + - GITEA_RUNNER_REGISTRATION_TOKEN=${CERC_GITEA_RUNNER_REGISTRATION_TOKEN:-eMdEwIzSo87nBh0UFWZlbp308j6TNWr3WhWxQqIc} + - GITEA_INSTANCE_URL=${CERC_GITEA_INSTANCE_URL:-http://gitea.local:3000} + - GITEA_RUNNER_LABELS=${CERC_GITEA_RUNNER_LABELS:-ubuntu-latest:docker://cerc/act-runner-task-executor:local,ubuntu-22.04:docker://cerc/act-runner-task-executor:local} + extra_hosts: + - "gitea.local:host-gateway" + volumes: + - /var/run/docker.sock:/var/run/docker.sock + - act-runner-data:/data + - act-runner-config:/config:ro + ports: + - 8088 + +volumes: + act-runner-data: + act-runner-config: diff --git a/act-runner/post_start.sh b/act-runner/post_start.sh new file mode 100755 index 0000000..5b948e4 --- /dev/null +++ b/act-runner/post_start.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +if [[ -n "$CERC_SCRIPT_DEBUG" ]]; then + set -x +fi diff --git a/act-runner/pre_start.sh b/act-runner/pre_start.sh new file mode 100755 index 0000000..5b948e4 --- /dev/null +++ b/act-runner/pre_start.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +if [[ -n "$CERC_SCRIPT_DEBUG" ]]; then + set -x +fi diff --git a/gitea/stack/deploy/commands.py b/act-runner/stack/deploy/commands.py similarity index 83% rename from gitea/stack/deploy/commands.py rename to act-runner/stack/deploy/commands.py index 50b94d2..d5e861b 100644 --- a/gitea/stack/deploy/commands.py +++ b/act-runner/stack/deploy/commands.py @@ -21,5 +21,6 @@ def create(context, extra_args): # Our goal here is just to copy the config file for act deployment_config_dir = context.deployment_dir.joinpath("data", "act-runner-config") - source_config_file = Path(context.command_context.cluster_context.compose_files[0]).parent.joinpath("config", "act-runner-config.yml") + compose_file = [f for f in context.command_context.cluster_context.compose_files if "act-runner" in f][0] + source_config_file = Path(compose_file).parent.joinpath("config", "act-runner-config.yml") copy(source_config_file, deployment_config_dir) diff --git a/gitea/README.md b/gitea/README.md index 082ab12..280720a 100644 --- a/gitea/README.md +++ b/gitea/README.md @@ -29,4 +29,4 @@ Details on how to setup remote debugging of the gitea server inside its containe #### Action Runners A Dockerized action runner is deployed by default for the labels `ubuntu-latest` and `ubuntu-22.04`. Details on deploying -additional runners can be found [here](act-runner.md). +additional runners can be found [here](../act-runner/act-runner.md). diff --git a/gitea/docker-compose.yml b/gitea/docker-compose.yml index 072f373..9e63253 100644 --- a/gitea/docker-compose.yml +++ b/gitea/docker-compose.yml @@ -42,28 +42,6 @@ services: volumes: - postgres-data:/var/lib/postgresql/data - runner: - image: cerc/act-runner:local - restart: always - environment: - # Note: eMdEwIzSo87nBh0UFWZlbp308j6TNWr3WhWxQqIc is a static token we use for convenience in stand-alone deployments. Not secure, obviously. - - GITEA_RUNNER_REGISTRATION_TOKEN=${CERC_GITEA_RUNNER_REGISTRATION_TOKEN:-eMdEwIzSo87nBh0UFWZlbp308j6TNWr3WhWxQqIc} - - GITEA_INSTANCE_URL=http://gitea.local:3000 - - GITEA_RUNNER_LABELS=ubuntu-latest:docker://cerc/act-runner-task-executor:local,ubuntu-22.04:docker://cerc/act-runner-task-executor:local - - CONFIG_FILE=/config/act-runner-config.yml - extra_hosts: - - "gitea.local:host-gateway" - volumes: - - /var/run/docker.sock:/var/run/docker.sock - - act-runner-data:/data - - act-runner-config:/config:ro - ports: - - 8088:8088 - - volumes: gitea-data: postgres-data: - act-runner-data: - act-runner-config: -