2024-04-07 14:53:48 +00:00
|
|
|
# Copyright 2024 The Forgejo Authors.
|
2023-08-24 10:28:17 +00:00
|
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
|
2023-09-04 16:19:15 +00:00
|
|
|
#
|
|
|
|
# Create a secret with:
|
|
|
|
#
|
|
|
|
# openssl rand -hex 20
|
|
|
|
#
|
|
|
|
# Replace all occurences of {SHARED_SECRET} below with the output.
|
|
|
|
#
|
|
|
|
# NOTE: a token obtained from the Forgejo web interface cannot be used
|
|
|
|
# as a shared secret.
|
|
|
|
#
|
|
|
|
# Replace {ROOT_PASSWORD} with a secure password
|
|
|
|
#
|
|
|
|
|
2024-04-07 16:07:00 +00:00
|
|
|
volumes:
|
|
|
|
docker_certs:
|
2023-08-24 10:28:17 +00:00
|
|
|
|
|
|
|
services:
|
|
|
|
|
|
|
|
docker-in-docker:
|
|
|
|
image: docker:dind
|
2024-04-07 16:07:00 +00:00
|
|
|
hostname: docker # Must set hostname as TLS certificates are only valid for docker or localhost
|
|
|
|
privileged: true
|
|
|
|
environment:
|
|
|
|
DOCKER_TLS_CERTDIR: /certs
|
|
|
|
DOCKER_HOST: docker-in-docker
|
|
|
|
volumes:
|
|
|
|
- docker_certs:/certs
|
2023-08-24 10:28:17 +00:00
|
|
|
|
|
|
|
forgejo:
|
2023-12-04 20:33:21 +00:00
|
|
|
image: codeberg.org/forgejo/forgejo:1.21
|
2023-08-24 10:28:17 +00:00
|
|
|
command: >-
|
|
|
|
bash -c '
|
|
|
|
/bin/s6-svscan /etc/s6 &
|
|
|
|
sleep 10 ;
|
2024-04-07 14:55:53 +00:00
|
|
|
su -c "forgejo forgejo-cli actions register --secret {SHARED_SECRET}" git ;
|
2023-09-04 16:19:15 +00:00
|
|
|
su -c "forgejo admin user create --admin --username root --password {ROOT_PASSWORD} --email root@example.com" git ;
|
2023-08-24 10:28:17 +00:00
|
|
|
sleep infinity
|
|
|
|
'
|
|
|
|
environment:
|
|
|
|
FORGEJO__security__INSTALL_LOCK: "true"
|
|
|
|
FORGEJO__log__LEVEL: "debug"
|
|
|
|
FORGEJO__repository__ENABLE_PUSH_CREATE_USER: "true"
|
|
|
|
FORGEJO__repository__DEFAULT_PUSH_CREATE_PRIVATE: "false"
|
|
|
|
FORGEJO__repository__DEFAULT_REPO_UNITS: "repo.code,repo.actions"
|
|
|
|
volumes:
|
|
|
|
- /srv/forgejo-data:/data
|
|
|
|
ports:
|
|
|
|
- 8080:3000
|
|
|
|
|
|
|
|
runner-register:
|
2024-04-07 14:55:22 +00:00
|
|
|
image: code.forgejo.org/forgejo/runner:3.4.1
|
2023-08-24 10:28:17 +00:00
|
|
|
links:
|
|
|
|
- docker-in-docker
|
|
|
|
- forgejo
|
|
|
|
environment:
|
2024-04-07 16:07:00 +00:00
|
|
|
DOCKER_HOST: tcp://docker-in-docker:2376
|
2023-08-24 10:28:17 +00:00
|
|
|
volumes:
|
|
|
|
- /srv/runner-data:/data
|
|
|
|
user: 0:0
|
|
|
|
command: >-
|
2023-10-06 14:19:55 +00:00
|
|
|
bash -ec '
|
2023-08-24 10:28:17 +00:00
|
|
|
while : ; do
|
2023-12-04 20:33:21 +00:00
|
|
|
forgejo-runner create-runner-file --connect --instance http://forgejo:3000 --name runner --secret {SHARED_SECRET} && break ;
|
2023-08-24 10:28:17 +00:00
|
|
|
sleep 1 ;
|
|
|
|
done ;
|
2024-04-07 16:07:00 +00:00
|
|
|
sed -i -e "s|\"labels\": null|\"labels\": [\"docker:docker://node:16-bullseye\", \"ubuntu-22.04:docker://catthehacker/ubuntu:act-22.04\"]|" .runner ;
|
2023-08-24 10:28:17 +00:00
|
|
|
forgejo-runner generate-config > config.yml ;
|
2023-10-06 14:18:09 +00:00
|
|
|
sed -i -e "s|network: .*|network: host|" config.yml ;
|
2024-04-07 16:07:00 +00:00
|
|
|
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 ;
|
|
|
|
sed -i -e "s|^ options:| options: -v /certs/client:/certs/client|" config.yml ;
|
|
|
|
sed -i -e "s| valid_volumes: \[\]$$| valid_volumes:\n - /certs/client|" config.yml ;
|
2023-08-24 10:28:17 +00:00
|
|
|
chown -R 1000:1000 /data
|
|
|
|
'
|
|
|
|
|
|
|
|
runner-daemon:
|
2024-04-07 14:55:22 +00:00
|
|
|
image: code.forgejo.org/forgejo/runner:3.4.1
|
2023-08-24 10:28:17 +00:00
|
|
|
links:
|
|
|
|
- docker-in-docker
|
|
|
|
- forgejo
|
|
|
|
environment:
|
2024-04-07 16:07:00 +00:00
|
|
|
DOCKER_HOST: tcp://docker:2376
|
|
|
|
DOCKER_CERT_PATH: /certs/client
|
|
|
|
DOCKER_TLS_VERIFY: "1"
|
2023-08-24 10:28:17 +00:00
|
|
|
volumes:
|
|
|
|
- /srv/runner-data:/data
|
2024-04-07 16:07:00 +00:00
|
|
|
- docker_certs:/certs
|
2024-04-07 18:34:23 +00:00
|
|
|
command: >-
|
|
|
|
bash -c '
|
|
|
|
while : ; do test -w .runner && forgejo-runner --config config.yml daemon ; sleep 1 ; done
|
|
|
|
'
|