mirror of https://code.forgejo.org/forgejo/runner
Merge pull request 'workaround: docker-compose example not using the specified labels (step 2)' (#177) from earl-warren/runner:wip-upgrade-example into main
Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/177wip-config
commit
8a2d4cb7cb
|
@ -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
|
||||
#
|
||||
|
@ -49,13 +56,14 @@ 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
|
||||
$cli logs runner-daemon > /tmp/runner.log
|
||||
grep --quiet 'Start image=node:20-bookworm' /tmp/runner.log
|
||||
|
||||
- name: docker compose logs
|
||||
- name: full docker compose logs
|
||||
if: always()
|
||||
run: |
|
||||
cd examples/docker-compose
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -1,15 +1,12 @@
|
|||
# Copyright 2023 The Forgejo Authors.
|
||||
# Copyright 2024 The Forgejo Authors.
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
services:
|
||||
|
||||
demo-workflow:
|
||||
image: alpine:3.18
|
||||
image: alpine:3.19
|
||||
links:
|
||||
- forgejo
|
||||
depends_on:
|
||||
runner-register:
|
||||
condition: service_completed_successfully
|
||||
command: >-
|
||||
sh -ec '
|
||||
apk add --quiet git curl jq ;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2023 The Forgejo Authors.
|
||||
# Copyright 2024 The Forgejo Authors.
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
#
|
||||
|
@ -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
|
||||
'
|
||||
|
@ -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
|
||||
|
@ -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 ;
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
'
|
||||
|
|
Loading…
Reference in New Issue