Compare commits

...
Sign in to create a new pull request.

1 commit

Author SHA1 Message Date
5004d16270 forgejo-runner: try to configure dind
Some checks failed
/ Ansible Lint (push) Failing after 2m38s
2026-07-04 12:50:26 +02:00
6 changed files with 57 additions and 1 deletions

View file

@ -1 +1,2 @@
forgejo_runner__config: "{{ lookup('ansible.builtin.template', 'resources/chaosknoten/forgejo-runner/forgejo-runner/configuration.yaml.j2') }}" forgejo_runner__config: "{{ lookup('ansible.builtin.template', 'resources/chaosknoten/forgejo-runner/forgejo-runner/configuration.yaml.j2') }}"
forgejo_runner__enable_dind: true

View file

@ -23,6 +23,8 @@ runner:
- alpine:docker://docker.io/library/alpine:latest - alpine:docker://docker.io/library/alpine:latest
# Debian # Debian
- debian:docker://docker.io/library/debian:latest - debian:docker://docker.io/library/debian:latest
envs:
DOCKER_HOST: tcp://dind_container.docker.internal:2375
cache: cache:
enabled: false enabled: false
@ -40,7 +42,8 @@ container:
## Add /etc/gvisor-helper-resolv.conf to valid_volumes to make the bind-mount in options work. ## Add /etc/gvisor-helper-resolv.conf to valid_volumes to make the bind-mount in options work.
## valid_volumes: ["/etc/gvisor-helper-resolv.conf:ro"] ## valid_volumes: ["/etc/gvisor-helper-resolv.conf:ro"]
# Leave "-", so no docker host will be mounted in the job container. # Leave "-", so no docker host will be mounted in the job container.
docker_host: "-" docker_host: "tcp://127.0.0.1:2376"
options: "--add-host=dind_container.docker.internal:host-gateway"
force_pull: true force_pull: true
force_rebuild: false force_rebuild: false

View file

@ -7,3 +7,8 @@ See: https://forgejo.org/docs/latest/admin/actions/
- `forgejo_runner__config`: The configuration to run the Forgejo Runner with. - `forgejo_runner__config`: The configuration to run the Forgejo Runner with.
A configuration can be generated using `forgejo-runner generate-config`. Also see the [relevant docs](https://forgejo.org/docs/latest/admin/actions/configuration/). A configuration can be generated using `forgejo-runner generate-config`. Also see the [relevant docs](https://forgejo.org/docs/latest/admin/actions/configuration/).
## Optional Arguments
- `forgejo_runner__enable_dind`: set up a Docker-in-Docker (dind) service alongside the runner.
You will need to adjust the runner configuration as explained in [Utilizing Docker within Actions: Docker-in-Docker](https://forgejo.org/docs/latest/admin/actions/docker-access/#docker-in-docker).

View file

@ -0,0 +1,2 @@
# Set up Docker in Docker on the runner host, and mount it into the runner
forgejo_runner__enable_dind: false

View file

@ -0,0 +1,24 @@
[Unit]
Description=Forgejo Docker in Docker
Documentation=https://forgejo.org/docs/latest/admin/actions/docker-access/#docker-in-docker
After=docker.service
Requires=docker.service
[Service]
ExecStart=/usr/bin/docker run \
-p 127.0.0.1:2376:2375 \
--rm \
--privileged \
--name dind_container \
docker:dind \
dockerd -H tcp://0.0.0.0:2375 --tls=false
ExecStop=/usr/bin/docker stop dind_container
User=runner
WorkingDirectory=/home/runner
Restart=on-failure
TimeoutSec=0
RestartSec=10
[Install]
WantedBy=multi-user.target

View file

@ -38,9 +38,30 @@
- systemd daemon reload - systemd daemon reload
- restart the forgejo-runner service - restart the forgejo-runner service
- name: ensure systemd service for dind exists
ansible.builtin.copy:
src: forgejo-docker-in-docker.service
dest: /etc/systemd/system/forgejo-docker-in-docker.service
owner: root
group: root
mode: "0644"
become: true
when: forgejo_runner__enable_dind
notify:
- systemd daemon reload
- restart the forgejo-runner service
- name: ensure systemd service is started and enabled - name: ensure systemd service is started and enabled
ansible.builtin.systemd_service: ansible.builtin.systemd_service:
name: forgejo-runner.service name: forgejo-runner.service
state: started state: started
enabled: true enabled: true
become: true become: true
- name: ensure systemd service for dind is started and enabled
ansible.builtin.systemd_service:
name: forgejo-docker-in-docker.service
state: started
enabled: true
become: true
when: forgejo_runner__enable_dind