WIP: wip-entrypoint #2

Draft
merith-tk wants to merge 18 commits from wip-entrypoint into main
3 changed files with 36 additions and 56 deletions
Showing only changes of commit 3c5ba1c1d2 - Show all commits

View file

@ -51,6 +51,7 @@ if [[ ! -f "${CONFIG_FILE}" ]]; then
sed -i "/^ network:/c\ network: host" ${CONFIG_FILE} sed -i "/^ network:/c\ network: host" ${CONFIG_FILE}
sed -i "/^ privileged:/c\ privileged: true" ${CONFIG_FILE} sed -i "/^ privileged:/c\ privileged: true" ${CONFIG_FILE}
sed -i "/^ options:/c\ options: -v /certs/client:/certs/client" ${CONFIG_FILE} sed -i "/^ options:/c\ options: -v /certs/client:/certs/client" ${CONFIG_FILE}
sed -i "/^ valid_volumes:/c\ valid_volumes:\n - /certs/client" ${CONFIG_FILE}
sed -i "/^ docker_host:/c\ docker_host: tcp://${DOCKER_HOST}:2376" ${CONFIG_FILE} sed -i "/^ docker_host:/c\ docker_host: tcp://${DOCKER_HOST}:2376" ${CONFIG_FILE}
fi fi

2
examples/docker-compose/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
forgejo/
forgejo-runner/

View file

@ -11,18 +11,23 @@
# NOTE: a token obtained from the Forgejo web interface cannot be used # NOTE: a token obtained from the Forgejo web interface cannot be used
# as a shared secret. # as a shared secret.
# #
# Replace {ROOT_PASSWORD} with a secure password # Replace {RUNNER_TOKEN} with the token obtained from the Forgejo web interface.
# #
networks:
forgejo:
volumes: volumes:
docker_certs: docker_certs:
services: services:
docker-in-docker: docker-in-docker:
image: code.forgejo.org/oci/docker:dind image: code.forgejo.org/oci/docker:dind
container_name: docker # needed for docker internal DNS resolution
hostname: docker # Must set hostname as TLS certificates are only valid for docker or localhost hostname: docker # Must set hostname as TLS certificates are only valid for docker or localhost
privileged: true privileged: true
networks:
- forgejo
environment: environment:
DOCKER_TLS_CERTDIR: /certs DOCKER_TLS_CERTDIR: /certs
DOCKER_HOST: docker-in-docker DOCKER_HOST: docker-in-docker
@ -31,63 +36,35 @@ services:
forgejo: forgejo:
image: codeberg.org/forgejo/forgejo:1.21 image: codeberg.org/forgejo/forgejo:1.21
command: >- container_name: forgejo
bash -c ' networks:
/bin/s6-svscan /etc/s6 & - forgejo
sleep 10 ;
su -c "forgejo forgejo-cli actions register --secret {SHARED_SECRET}" git ;
su -c "forgejo admin user create --admin --username root --password {ROOT_PASSWORD} --email root@example.com" git ;
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: volumes:
- /srv/forgejo-data:/data - ./forgejo:/data
ports: ports:
- 8080:3000 - 8080:3000
runner-register: forgejo-runner:
image: code.forgejo.org/forgejo/runner:3.4.1 ## TODO: Update image to the the release
links: ## made from this PR: https://code.forgejo.org/forgejo/runner/pulls/283
- docker-in-docker
- forgejo # image: code.forgejo.org/forgejo/runner:3.4.1
environment: build: ../../
DOCKER_HOST: tcp://docker-in-docker:2376 container_name: forgejo-runner
volumes: volumes:
- /srv/runner-data:/data - ./forgejo-runner:/data
user: 0:0
command: >-
bash -ec '
while : ; do
forgejo-runner create-runner-file --connect --instance http://forgejo:3000 --name runner --secret {SHARED_SECRET} && break ;
sleep 1 ;
done ;
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 ;
forgejo-runner generate-config > config.yml ;
sed -i -e "s|network: .*|network: host|" config.yml ;
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 ;
chown -R 1000:1000 /data
'
runner-daemon:
image: code.forgejo.org/forgejo/runner:3.4.1
links:
- docker-in-docker
- forgejo
environment:
DOCKER_HOST: tcp://docker:2376
DOCKER_CERT_PATH: /certs/client
DOCKER_TLS_VERIFY: "1"
volumes:
- /srv/runner-data:/data
- docker_certs:/certs - docker_certs:/certs
command: >- networks:
bash -c ' - forgejo
while : ; do test -w .runner && forgejo-runner --config config.yml daemon ; sleep 1 ; done depends_on:
' - docker-in-docker
- forgejo
environment:
CONFIG_FILE: config.yml # defaults to /data/config.yml
FORGEJO_URL: ${FORGEJO_URL} # defaults to http://forgejo:3000
RUNNER_FILE: runner.json # defaults to /data/runner.json
RUNNER_NAME: forgejo-runner # defaults to forgejo-runner, used for registration
RUNNER_TOKEN: "{RUNNER_TOKEN}"
RUNNER_USER: 1000 # defaults to 1000