From 4ad4512814db4f15294d0d0195c7a34b2a8a317a Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sun, 7 Apr 2024 16:53:48 +0200 Subject: [PATCH 1/7] docker-compose example: documentation updates --- examples/docker-compose/README.md | 19 ++++++++++++++----- .../docker-compose/compose-demo-workflow.yml | 2 +- .../compose-forgejo-and-runner.yml | 2 +- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/examples/docker-compose/README.md b/examples/docker-compose/README.md index 08738c8..a3e6e9b 100644 --- a/examples/docker-compose/README.md +++ b/examples/docker-compose/README.md @@ -13,10 +13,19 @@ rm -fr /srv/runner-data /srv/forgejo-data secret=$(openssl rand -hex 20) sed -i -e "s/{SHARED_SECRET}/$secret/" compose-forgejo-and-runner.yml docker compose -f compose-forgejo-and-runner.yml up -d -docker compose -f compose-forgejo-and-runner.yml -f compose-demo-workflow.yml up demo-workflow -firefox http://0.0.0.0:8080/root/test/actions/runs/1 # login root, password {ROOT_PASSWORD} ``` +Visit http://0.0.0.0:8080/admin/actions/runners with login `root` and password `{ROOT_PASSWORD}` and see the runner is registered with the label `docker`. + +> NOTE: the `Your ROOT_URL in app.ini is "http://localhost:3000/", it's unlikely matching the site you are visiting.` message is a warning that can be ignored in the context of this example. + +```sh +docker compose -f compose-forgejo-and-runner.yml -f compose-demo-workflow.yml up demo-workflow +``` + +Visit http://0.0.0.0:8080/root/test/actions/runs/1 and see that the job ran. + + ### Running Create a shared secret with: @@ -34,7 +43,7 @@ Replace {ROOT_PASSWORD} with a secure password in [compose-forgejo-and-runner.yml](compose-forgejo-and-runner.yml). ```sh -docker-compose -f compose-forgejo-and-runner.yml up +docker compose -f compose-forgejo-and-runner.yml up Creating docker-compose_docker-in-docker_1 ... done Creating docker-compose_forgejo_1 ... done Creating docker-compose_runner-register_1 ... done @@ -51,8 +60,8 @@ runner-daemon_1 | time="2023-08-24T10:22:16Z" level=info msg="Starting runne To login the Forgejo instance: * URL: http://0.0.0.0:8080 -* user: root -* password: {ROOT_PASSWORD} +* user: `root` +* password: `{ROOT_PASSWORD}` `Forgejo Actions` is enabled by default when creating a repository. diff --git a/examples/docker-compose/compose-demo-workflow.yml b/examples/docker-compose/compose-demo-workflow.yml index 1466635..aa2fe31 100644 --- a/examples/docker-compose/compose-demo-workflow.yml +++ b/examples/docker-compose/compose-demo-workflow.yml @@ -1,4 +1,4 @@ -# Copyright 2023 The Forgejo Authors. +# Copyright 2024 The Forgejo Authors. # SPDX-License-Identifier: MIT services: diff --git a/examples/docker-compose/compose-forgejo-and-runner.yml b/examples/docker-compose/compose-forgejo-and-runner.yml index 1269a92..48147a7 100644 --- a/examples/docker-compose/compose-forgejo-and-runner.yml +++ b/examples/docker-compose/compose-forgejo-and-runner.yml @@ -1,4 +1,4 @@ -# Copyright 2023 The Forgejo Authors. +# Copyright 2024 The Forgejo Authors. # SPDX-License-Identifier: MIT # From e7076aefb8ae9a52ae0630b33e0d70da700ceeb4 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sun, 7 Apr 2024 16:55:22 +0200 Subject: [PATCH 2/7] docker-compose example: upgrade runner & alpine --- examples/docker-compose/compose-demo-workflow.yml | 2 +- examples/docker-compose/compose-forgejo-and-runner.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/docker-compose/compose-demo-workflow.yml b/examples/docker-compose/compose-demo-workflow.yml index aa2fe31..5c327e2 100644 --- a/examples/docker-compose/compose-demo-workflow.yml +++ b/examples/docker-compose/compose-demo-workflow.yml @@ -4,7 +4,7 @@ services: demo-workflow: - image: alpine:3.18 + image: alpine:3.19 links: - forgejo depends_on: diff --git a/examples/docker-compose/compose-forgejo-and-runner.yml b/examples/docker-compose/compose-forgejo-and-runner.yml index 48147a7..1cf58ed 100644 --- a/examples/docker-compose/compose-forgejo-and-runner.yml +++ b/examples/docker-compose/compose-forgejo-and-runner.yml @@ -51,7 +51,7 @@ services: - 8080:3000 runner-register: - image: code.forgejo.org/forgejo/runner:3.3.0 + image: code.forgejo.org/forgejo/runner:3.4.1 links: - docker-in-docker - forgejo @@ -76,7 +76,7 @@ services: ' runner-daemon: - image: code.forgejo.org/forgejo/runner:3.3.0 + image: code.forgejo.org/forgejo/runner:3.4.1 links: - docker-in-docker - forgejo From e385811e746c8c3f93cf3f340d12f686e6d79018 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sun, 7 Apr 2024 16:55:53 +0200 Subject: [PATCH 3/7] docker-compose example: remove obsolete runner options --- examples/docker-compose/compose-forgejo-and-runner.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/docker-compose/compose-forgejo-and-runner.yml b/examples/docker-compose/compose-forgejo-and-runner.yml index 1cf58ed..0ea195d 100644 --- a/examples/docker-compose/compose-forgejo-and-runner.yml +++ b/examples/docker-compose/compose-forgejo-and-runner.yml @@ -35,7 +35,7 @@ services: bash -c ' /bin/s6-svscan /etc/s6 & sleep 10 ; - su -c "forgejo forgejo-cli actions register --secret {SHARED_SECRET} --labels docker,ubuntu-22.04 --version 3.3.0" git ; + su -c "forgejo forgejo-cli actions register --secret {SHARED_SECRET}" git ; su -c "forgejo admin user create --admin --username root --password {ROOT_PASSWORD} --email root@example.com" git ; sleep infinity ' From 82b6df801ff3db38477a1876ef839c14e11d20c6 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sun, 7 Apr 2024 20:34:23 +0200 Subject: [PATCH 4/7] docker-compose example: do not use depends_on Wait for the .runner file to exist instead as a proof that the runner is ready to accept a job --- examples/docker-compose/compose-demo-workflow.yml | 3 --- examples/docker-compose/compose-forgejo-and-runner.yml | 8 ++++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/examples/docker-compose/compose-demo-workflow.yml b/examples/docker-compose/compose-demo-workflow.yml index 5c327e2..6b1d561 100644 --- a/examples/docker-compose/compose-demo-workflow.yml +++ b/examples/docker-compose/compose-demo-workflow.yml @@ -7,9 +7,6 @@ services: image: alpine:3.19 links: - forgejo - depends_on: - runner-register: - condition: service_completed_successfully command: >- sh -ec ' apk add --quiet git curl jq ; diff --git a/examples/docker-compose/compose-forgejo-and-runner.yml b/examples/docker-compose/compose-forgejo-and-runner.yml index 0ea195d..600825e 100644 --- a/examples/docker-compose/compose-forgejo-and-runner.yml +++ b/examples/docker-compose/compose-forgejo-and-runner.yml @@ -84,10 +84,10 @@ services: DOCKER_HOST: tcp://docker:2376 DOCKER_CERT_PATH: /certs/client DOCKER_TLS_VERIFY: "1" - depends_on: - runner-register: - condition: service_completed_successfully volumes: - /srv/runner-data:/data - docker_certs:/certs - command: "forgejo-runner --config config.yml daemon" + command: >- + bash -c ' + while : ; do test -w .runner && forgejo-runner --config config.yml daemon ; sleep 1 ; done + ' From ed946d0f549a69972293422ce2115085e4e62cc4 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sun, 7 Apr 2024 17:04:38 +0200 Subject: [PATCH 5/7] docker-compose example: wait for Forgejo and the runner Do not launch the demo workflow right away so it is easier to separate the failures in the CI. --- .forgejo/workflows/example-docker-compose.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.forgejo/workflows/example-docker-compose.yml b/.forgejo/workflows/example-docker-compose.yml index 174e0d5..fe2cace 100644 --- a/.forgejo/workflows/example-docker-compose.yml +++ b/.forgejo/workflows/example-docker-compose.yml @@ -34,11 +34,18 @@ jobs: cd examples/docker-compose secret=$(openssl rand -hex 20) sed -i -e "s/{SHARED_SECRET}/$secret/" compose-forgejo-and-runner.yml - cli="docker compose --progress quiet -f compose-forgejo-and-runner.yml -f compose-demo-workflow.yml" + cli="docker compose --progress quiet -f compose-forgejo-and-runner.yml" # - # Launch + # Launch Forgejo & the runner # $cli up -d + for delay in $(seq 60) ; do test -f /srv/runner-data/.runner && break ; sleep 30 ; done + test -f /srv/runner-data/.runner + # + # Run the demo workflow + # + cli="$cli -f compose-demo-workflow.yml" + $cli up -d demo-workflow # # Wait for the demo workflow to complete # From 4c05530aa3557f616e5a431c35b035a56f2bb18d Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sun, 7 Apr 2024 17:05:55 +0200 Subject: [PATCH 6/7] docker-compose example: also show the runner output in the CI --- .forgejo/workflows/example-docker-compose.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.forgejo/workflows/example-docker-compose.yml b/.forgejo/workflows/example-docker-compose.yml index fe2cace..b215ba4 100644 --- a/.forgejo/workflows/example-docker-compose.yml +++ b/.forgejo/workflows/example-docker-compose.yml @@ -56,13 +56,12 @@ jobs: grep --quiet "$success" /tmp/out && break grep --quiet "$failure" /tmp/out && break $cli ps --all - tail /tmp/out - sleep 10 + $cli logs --tail=20 runner-daemon demo-workflow + sleep 30 done - tail /tmp/out grep --quiet "$success" /tmp/out - - name: docker compose logs + - name: full docker compose logs if: always() run: | cd examples/docker-compose From 0348074eee55df545b25a2ff5a506bd657fbea9d Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sun, 7 Apr 2024 20:44:41 +0200 Subject: [PATCH 7/7] docker-compose example: use node:20-bookworm instead of the default --- .forgejo/workflows/example-docker-compose.yml | 2 ++ examples/docker-compose/compose-forgejo-and-runner.yml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.forgejo/workflows/example-docker-compose.yml b/.forgejo/workflows/example-docker-compose.yml index b215ba4..f0c8e01 100644 --- a/.forgejo/workflows/example-docker-compose.yml +++ b/.forgejo/workflows/example-docker-compose.yml @@ -60,6 +60,8 @@ jobs: sleep 30 done grep --quiet "$success" /tmp/out + $cli logs runner-daemon > /tmp/runner.log + grep --quiet 'Start image=node:20-bookworm' /tmp/runner.log - name: full docker compose logs if: always() diff --git a/examples/docker-compose/compose-forgejo-and-runner.yml b/examples/docker-compose/compose-forgejo-and-runner.yml index 600825e..4a54761 100644 --- a/examples/docker-compose/compose-forgejo-and-runner.yml +++ b/examples/docker-compose/compose-forgejo-and-runner.yml @@ -66,7 +66,7 @@ services: forgejo-runner create-runner-file --connect --instance http://forgejo:3000 --name runner --secret {SHARED_SECRET} && break ; sleep 1 ; done ; - sed -i -e "s|\"labels\": null|\"labels\": [\"docker:docker://node:16-bullseye\", \"ubuntu-22.04:docker://catthehacker/ubuntu:act-22.04\"]|" .runner ; + sed -i -e "s|\"labels\": null|\"labels\": [\"docker:docker://node:20-bookworm\", \"ubuntu-22.04:docker://catthehacker/ubuntu:act-22.04\"]|" .runner ; forgejo-runner generate-config > config.yml ; sed -i -e "s|network: .*|network: host|" config.yml ; sed -i -e "s|^ envs:$$| envs:\n DOCKER_HOST: tcp://docker:2376\n DOCKER_TLS_VERIFY: 1\n DOCKER_CERT_PATH: /certs/client|" config.yml ;