2023-08-24 05:28:17 -05:00
|
|
|
# Copyright 2023 The Forgejo Authors.
|
|
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
|
2023-09-04 11:19:15 -05: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
|
|
|
|
#
|
|
|
|
|
2023-08-24 05:28:17 -05:00
|
|
|
version: "3"
|
|
|
|
|
|
|
|
services:
|
|
|
|
|
|
|
|
docker-in-docker:
|
|
|
|
image: docker:dind
|
|
|
|
privileged: true
|
|
|
|
command: [ "dockerd", "-H", "tcp://0.0.0.0:2375", "--tls=false" ]
|
|
|
|
|
|
|
|
forgejo:
|
2023-12-04 14:33:21 -06:00
|
|
|
image: codeberg.org/forgejo/forgejo:1.21
|
2023-08-24 05:28:17 -05:00
|
|
|
command: >-
|
|
|
|
bash -c '
|
|
|
|
/bin/s6-svscan /etc/s6 &
|
|
|
|
sleep 10 ;
|
2023-12-04 14:33:21 -06:00
|
|
|
su -c "forgejo forgejo-cli actions register --secret {SHARED_SECRET} --labels docker --version 3.3.0" git ;
|
2023-09-04 11:19:15 -05:00
|
|
|
su -c "forgejo admin user create --admin --username root --password {ROOT_PASSWORD} --email root@example.com" git ;
|
2023-08-24 05:28:17 -05: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:
|
2023-12-04 14:33:21 -06:00
|
|
|
image: code.forgejo.org/forgejo/runner:3.3.0
|
2023-08-24 05:28:17 -05:00
|
|
|
links:
|
|
|
|
- docker-in-docker
|
|
|
|
- forgejo
|
|
|
|
environment:
|
|
|
|
DOCKER_HOST: tcp://docker-in-docker:2375
|
|
|
|
volumes:
|
|
|
|
- /srv/runner-data:/data
|
|
|
|
user: 0:0
|
|
|
|
command: >-
|
2023-10-06 09:19:55 -05:00
|
|
|
bash -ec '
|
2023-08-24 05:28:17 -05:00
|
|
|
while : ; do
|
2023-12-04 14:33:21 -06:00
|
|
|
forgejo-runner create-runner-file --connect --instance http://forgejo:3000 --name runner --secret {SHARED_SECRET} && break ;
|
2023-08-24 05:28:17 -05:00
|
|
|
sleep 1 ;
|
|
|
|
done ;
|
|
|
|
forgejo-runner generate-config > config.yml ;
|
2023-10-06 09:18:09 -05:00
|
|
|
sed -i -e "s|network: .*|network: host|" config.yml ;
|
2023-08-24 05:28:17 -05:00
|
|
|
sed -i -e "s|labels: \[\]|labels: \[\"docker:docker://alpine:3.18\"\]|" config.yml ;
|
|
|
|
chown -R 1000:1000 /data
|
|
|
|
'
|
|
|
|
|
|
|
|
runner-daemon:
|
2023-12-04 14:33:21 -06:00
|
|
|
image: code.forgejo.org/forgejo/runner:3.3.0
|
2023-08-24 05:28:17 -05:00
|
|
|
links:
|
|
|
|
- docker-in-docker
|
|
|
|
- forgejo
|
|
|
|
environment:
|
|
|
|
DOCKER_HOST: tcp://docker-in-docker:2375
|
|
|
|
depends_on:
|
|
|
|
runner-register:
|
|
|
|
condition: service_completed_successfully
|
|
|
|
volumes:
|
|
|
|
- /srv/runner-data:/data
|
|
|
|
command: "forgejo-runner --config config.yml daemon"
|