1# Copyright 2024 The Forgejo Authors.2# SPDX-License-Identifier: MIT34#5# Create a secret with:6#7# openssl rand -hex 208#9# Replace all occurences of {SHARED_SECRET} below with the output.10#11# NOTE: a token obtained from the Forgejo web interface cannot be used12# as a shared secret.13#14# Replace {ROOT_PASSWORD} with a secure password15#1617volumes:18 docker_certs:1920services:2122 docker-in-docker:23 image: code.forgejo.org/oci/docker:dind24 hostname: docker # Must set hostname as TLS certificates are only valid for docker or localhost25 privileged: true26 environment:27 DOCKER_TLS_CERTDIR: /certs28 DOCKER_HOST: docker-in-docker29 volumes:30 - docker_certs:/certs3132 forgejo:33 image: codeberg.org/forgejo/forgejo:1.2134 command: >-35 bash -c '36 /bin/s6-svscan /etc/s6 &37 sleep 10 ;38 su -c "forgejo forgejo-cli actions register --secret {SHARED_SECRET}" git ;39 su -c "forgejo admin user create --admin --username root --password {ROOT_PASSWORD} --email root@example.com" git ;40 sleep infinity41 '42 environment:43 FORGEJO__security__INSTALL_LOCK: "true"44 FORGEJO__log__LEVEL: "debug"45 FORGEJO__repository__ENABLE_PUSH_CREATE_USER: "true"46 FORGEJO__repository__DEFAULT_PUSH_CREATE_PRIVATE: "false"47 FORGEJO__repository__DEFAULT_REPO_UNITS: "repo.code,repo.actions"48 volumes:49 - /srv/forgejo-data:/data50 ports:51 - 8080:30005253 runner-register:54 image: code.forgejo.org/forgejo/runner:3.4.155 links:56 - docker-in-docker57 - forgejo58 environment:59 DOCKER_HOST: tcp://docker-in-docker:237660 volumes:61 - /srv/runner-data:/data62 user: 0:063 command: >-64 bash -ec '65 while : ; do66 forgejo-runner create-runner-file --connect --instance http://forgejo:3000 --name runner --secret {SHARED_SECRET} && break ;67 sleep 1 ;68 done ;69 sed -i -e "s|\"labels\": null|\"labels\": [\"docker:docker://code.forgejo.org/oci/node:20-bookworm\", \"ubuntu-22.04:docker://catthehacker/ubuntu:act-22.04\"]|" .runner ;70 forgejo-runner generate-config > config.yml ;71 sed -i -e "s|network: .*|network: host|" config.yml ;72 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 ;73 sed -i -e "s|^ options:| options: -v /certs/client:/certs/client|" config.yml ;74 sed -i -e "s| valid_volumes: \[\]$$| valid_volumes:\n - /certs/client|" config.yml ;75 chown -R 1000:1000 /data76 '7778 runner-daemon:79 image: code.forgejo.org/forgejo/runner:3.4.180 links:81 - docker-in-docker82 - forgejo83 environment:84 DOCKER_HOST: tcp://docker:237685 DOCKER_CERT_PATH: /certs/client86 DOCKER_TLS_VERIFY: "1"87 volumes:88 - /srv/runner-data:/data89 - docker_certs:/certs90 command: >-91 bash -c '92 while : ; do test -w .runner && forgejo-runner --config config.yml daemon ; sleep 1 ; done93 '