2024-04-07 15:53:48 +01:00
|
|
|
# Copyright 2024 The Forgejo Authors.
|
2023-08-24 11:28:17 +01:00
|
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
|
2023-09-04 17:19:15 +01:00
|
|
|
#
|
|
|
|
# Create a secret with:
|
|
|
|
#
|
|
|
|
# openssl rand -hex 20
|
|
|
|
#
|
|
|
|
# Replace all occurences of {SHARED_SECRET} below with the output.
|
2024-09-26 23:08:31 +01:00
|
|
|
#
|
2023-09-04 17:19:15 +01:00
|
|
|
# NOTE: a token obtained from the Forgejo web interface cannot be used
|
|
|
|
# as a shared secret.
|
|
|
|
#
|
2024-09-25 23:21:53 +01:00
|
|
|
# Replace ${RUNNER_TOKEN} with the token obtained from the Forgejo web interface.
|
2023-09-04 17:19:15 +01:00
|
|
|
#
|
2024-09-28 18:31:13 +01:00
|
|
|
# Replace {ROOT_PASSWORD} with a secure password.
|
2024-09-27 18:38:59 +01:00
|
|
|
#
|
2024-04-07 17:07:00 +01:00
|
|
|
volumes:
|
|
|
|
docker_certs:
|
2023-08-24 11:28:17 +01:00
|
|
|
|
|
|
|
services:
|
|
|
|
docker-in-docker:
|
2024-08-13 13:00:37 +01:00
|
|
|
image: code.forgejo.org/oci/docker:dind
|
2024-09-27 03:00:54 +01:00
|
|
|
hostname: docker # Must set hostname for both internal DNS and TLS to work as certs are only valid for docker and localhost
|
2024-09-27 18:38:59 +01:00
|
|
|
restart: unless-stopped
|
2024-08-13 07:37:52 +01:00
|
|
|
privileged: true
|
2024-04-07 17:07:00 +01:00
|
|
|
environment:
|
2024-09-26 23:08:31 +01:00
|
|
|
DOCKER_TLS_CERTDIR: "/certs" # set to "" to disable the use of TLS, also manually update existing runner configs to use port 2375
|
2024-09-27 18:38:59 +01:00
|
|
|
DOCKER_HOST: "docker" # remove aswell to disable TLS
|
2024-04-07 17:07:00 +01:00
|
|
|
volumes:
|
|
|
|
- docker_certs:/certs
|
2023-08-24 11:28:17 +01:00
|
|
|
|
|
|
|
forgejo:
|
2023-12-04 20:33:21 +00:00
|
|
|
image: codeberg.org/forgejo/forgejo:1.21
|
2024-09-26 23:08:31 +01:00
|
|
|
hostname: forgejo
|
2023-08-24 11:28:17 +01:00
|
|
|
volumes:
|
2024-09-27 03:00:54 +01:00
|
|
|
- /srv/forgejo-data:/data
|
2023-08-24 11:28:17 +01:00
|
|
|
ports:
|
|
|
|
- 8080:3000
|
2024-09-27 18:38:59 +01:00
|
|
|
environment:
|
|
|
|
FORGEJO__security__INSTALL_LOCK: "true" # remove in production
|
2024-09-28 18:36:47 +01:00
|
|
|
FORGEJO__log__LEVEL: "debug" # remove in production
|
|
|
|
FORGEJO__repository__ENABLE_PUSH_CREATE_USER: "true" # enables the ability to create a repo when pushing
|
|
|
|
FORGEJO__repository__DEFAULT_PUSH_CREATE_PRIVATE: "false" # defaults above to public
|
|
|
|
FORGEJO__repository__DEFAULT_REPO_UNITS: "repo.code,repo.actions"
|
|
|
|
# `command` is not neecessary, but can be used to create an admin user as shown below when combined with INSTALL_LOCK
|
2024-09-25 23:21:53 +01:00
|
|
|
command: >-
|
|
|
|
bash -c '
|
|
|
|
/bin/s6-svscan /etc/s6 &
|
|
|
|
sleep 10 ;
|
2024-09-28 18:31:13 +01:00
|
|
|
su -c "forgejo admin user create --admin --username root --password {ROOT_PASSWORD} --email root@example.com" git ;
|
2024-09-25 23:21:53 +01:00
|
|
|
su -c "forgejo forgejo-cli actions register --secret {SHARED_SECRET}" git ;
|
|
|
|
sleep infinity
|
|
|
|
'
|
2023-08-24 11:28:17 +01:00
|
|
|
|
2024-09-26 23:08:31 +01:00
|
|
|
# all values that have defaults listed are optional
|
2024-09-27 18:38:59 +01:00
|
|
|
# only FORGEJO_SECRET or RUNNER_TOKEN is required, the secret will be prioritized
|
|
|
|
# FORGEJO_URL is required if forgejo is not in this compose file or docker network
|
2024-09-27 03:00:54 +01:00
|
|
|
runner-daemon:
|
2024-09-25 22:05:56 +01:00
|
|
|
## TODO: Update image to the the release
|
|
|
|
## made from this PR: https://code.forgejo.org/forgejo/runner/pulls/283
|
2024-09-26 23:08:31 +01:00
|
|
|
|
|
|
|
# image: code.forgejo.org/forgejo/runner:3.4.1
|
|
|
|
build: ../../
|
2024-09-27 18:38:59 +01:00
|
|
|
user: "1000" # defaults to 1000,
|
2024-09-27 03:00:54 +01:00
|
|
|
restart: unless-stopped # needed for fixing file ownership on restart
|
2023-08-24 11:28:17 +01:00
|
|
|
volumes:
|
2024-09-27 03:00:54 +01:00
|
|
|
- /srv/runner-data:/data
|
2024-09-25 22:05:56 +01:00
|
|
|
- docker_certs:/certs
|
|
|
|
depends_on:
|
2023-08-24 11:28:17 +01:00
|
|
|
- docker-in-docker
|
|
|
|
- forgejo
|
2024-09-28 18:31:13 +01:00
|
|
|
links:
|
|
|
|
- forgejo
|
|
|
|
- docker-in-docker
|
2023-08-24 11:28:17 +01:00
|
|
|
environment:
|
2024-09-26 23:08:31 +01:00
|
|
|
CONFIG_FILE: config.yml # defaults to /data/config.yml
|
2024-09-25 22:05:56 +01:00
|
|
|
|
2024-09-27 03:00:54 +01:00
|
|
|
DOCKER_HOST: "tcp://docker:2376" # defaults to tcp://docker:2376
|
|
|
|
DOCKER_CERT_PATH: "/certs/client" # defaults to /certs/client
|
2024-09-27 18:38:59 +01:00
|
|
|
DOCKER_TLS_VERIFY: "1" # defaults to 1
|
2024-09-25 23:21:53 +01:00
|
|
|
|
2024-09-26 23:08:31 +01:00
|
|
|
FORGEJO_URL: ${FORGEJO_URL} # defaults to http://forgejo:3000
|
|
|
|
FORGEJO_SECRET: "{SHARED_SECRET}" # shared secret, must match Forgejo's, overrides RUNNER_TOKEN
|
2024-09-25 23:21:53 +01:00
|
|
|
|
2024-09-26 23:08:31 +01:00
|
|
|
RUNNER_FILE: .runner # defaults to /data/runner.json
|
2024-09-27 03:00:54 +01:00
|
|
|
RUNNER_NAME: runner-daemon # defaults to forgejo-runner, used for registration
|
|
|
|
RUNNER_TOKEN: ${RUNNER_TOKEN} # token obtained from Forgejo web interface
|
2024-09-25 23:21:53 +01:00
|
|
|
|
2024-09-26 23:08:31 +01:00
|
|
|
DEBUG: "true" # defaults to false, set to true to enable debug logging
|
|
|
|
SKIP_WAIT: "false" # defaults to false, set to true to skip the 10 second wait to allow for forgejo and docker-in-docker to start
|