diff --git a/public/svgs/forgejo.svg b/public/svgs/forgejo.svg new file mode 100644 index 000000000..804b05e28 --- /dev/null +++ b/public/svgs/forgejo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/templates/compose/forgejo-with-mariadb.yaml b/templates/compose/forgejo-with-mariadb.yaml new file mode 100644 index 000000000..92e7843f1 --- /dev/null +++ b/templates/compose/forgejo-with-mariadb.yaml @@ -0,0 +1,49 @@ +# documentation: https://forgejo.org/docs +# slogan: Forgejo is a self-hosted lightweight software forge. Easy to install and low maintenance, it just does the job. +# tags: version control, collaboration, code, hosting, lightweight, mariadb +# logo: svgs/forgejo.svg + +services: + forgejo: + image: codeberg.org/forgejo/forgejo:7 + environment: + - SERVICE_FQDN_FORGEJO_3000 + - FORGEJO__server__ROOT_URL=${SERVICE_FQDN_FORGEJO} + - FORGEJO__migrations__ALLOWED_DOMAINS=${FORGEJO__migrations__ALLOWED_DOMAINS} + - FORGEJO__migrations__ALLOW_LOCALNETWORKS=${FORGEJO__migrations__ALLOW_LOCALNETWORKS-false} + - USER_UID=1000 + - USER_GID=1000 + - FORGEJO__database__DB_TYPE=mysql + - FORGEJO__database__HOST=mariadb + - FORGEJO__database__NAME=${MYSQL_DATABASE-forgejo} + - FORGEJO__database__USER=$SERVICE_USER_MYSQL + - FORGEJO__database__PASSWD=$SERVICE_PASSWORD_MYSQL + volumes: + - forgejo-data:/data + - forgejo-timezone:/etc/timezone:ro + - forgejo-localtime:/etc/localtime:ro + ports: + - 22222:22 + depends_on: + mariadb: + condition: service_healthy + healthcheck: + test: ["CMD", "curl", "-f", "http://127.0.0.1:3000"] + interval: 2s + timeout: 10s + retries: 15 + + mariadb: + image: mariadb:11 + volumes: + - forgejo-mariadb-data:/var/lib/mysql + environment: + - MYSQL_USER=${SERVICE_USER_MYSQL} + - MYSQL_PASSWORD=${SERVICE_PASSWORD_MYSQL} + - MYSQL_DATABASE=${MYSQL_DATABASE} + - MYSQL_ROOT_PASSWORD=${SERVICE_PASSWORD_MYSQLROOT} + healthcheck: + test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] + interval: 5s + timeout: 20s + retries: 10 diff --git a/templates/compose/forgejo-with-mysql.yaml b/templates/compose/forgejo-with-mysql.yaml new file mode 100644 index 000000000..9b2359c08 --- /dev/null +++ b/templates/compose/forgejo-with-mysql.yaml @@ -0,0 +1,49 @@ +# documentation: https://forgejo.org/docs +# slogan: Forgejo is a self-hosted lightweight software forge. Easy to install and low maintenance, it just does the job. +# tags: version control, collaboration, code, hosting, lightweight, mysql +# logo: svgs/forgejo.svg + +services: + forgejo: + image: codeberg.org/forgejo/forgejo:7 + environment: + - SERVICE_FQDN_FORGEJO_3000 + - FORGEJO__server__ROOT_URL=${SERVICE_FQDN_FORGEJO} + - FORGEJO__migrations__ALLOWED_DOMAINS=${FORGEJO__migrations__ALLOWED_DOMAINS} + - FORGEJO__migrations__ALLOW_LOCALNETWORKS=${FORGEJO__migrations__ALLOW_LOCALNETWORKS-false} + - USER_UID=1000 + - USER_GID=1000 + - FORGEJO__database__DB_TYPE=mysql + - FORGEJO__database__HOST=mysql + - FORGEJO__database__NAME=${MYSQL_DATABASE-forgejo} + - FORGEJO__database__USER=$SERVICE_USER_MYSQL + - FORGEJO__database__PASSWD=$SERVICE_PASSWORD_MYSQL + volumes: + - forgejo-data:/data + - forgejo-timezone:/etc/timezone:ro + - forgejo-localtime:/etc/localtime:ro + ports: + - 22222:22 + depends_on: + mysql: + condition: service_healthy + healthcheck: + test: ["CMD", "curl", "-f", "http://127.0.0.1:3000"] + interval: 2s + timeout: 10s + retries: 15 + + mysql: + image: mysql:8 + volumes: + - forgejo-mysql-data:/var/lib/mysql + environment: + - MYSQL_USER=${SERVICE_USER_MYSQL} + - MYSQL_PASSWORD=${SERVICE_PASSWORD_MYSQL} + - MYSQL_DATABASE=${MYSQL_DATABASE} + - MYSQL_ROOT_PASSWORD=${SERVICE_PASSWORD_MYSQLROOT} + healthcheck: + test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1"] + interval: 5s + timeout: 20s + retries: 10 diff --git a/templates/compose/forgejo-with-postgresql.yaml b/templates/compose/forgejo-with-postgresql.yaml new file mode 100644 index 000000000..2a7596074 --- /dev/null +++ b/templates/compose/forgejo-with-postgresql.yaml @@ -0,0 +1,48 @@ +# documentation: https://forgejo.org/docs +# slogan: Forgejo is a self-hosted lightweight software forge. Easy to install and low maintenance, it just does the job. +# tags: version control, collaboration, code, hosting, lightweight, postgresql +# logo: svgs/forgejo.svg + +services: + forgejo: + image: codeberg.org/forgejo/forgejo:7 + environment: + - SERVICE_FQDN_FORGEJO_3000 + - FORGEJO__server__ROOT_URL=${SERVICE_FQDN_FORGEJO} + - FORGEJO__migrations__ALLOWED_DOMAINS=${FORGEJO__migrations__ALLOWED_DOMAINS} + - FORGEJO__migrations__ALLOW_LOCALNETWORKS=${FORGEJO__migrations__ALLOW_LOCALNETWORKS-false} + - USER_UID=1000 + - USER_GID=1000 + - FORGEJO__database__DB_TYPE=postgres + - FORGEJO__database__HOST=postgresql + - FORGEJO__database__NAME=${POSTGRESQL_DATABASE-forgejo} + - FORGEJO__database__USER=$SERVICE_USER_POSTGRESQL + - FORGEJO__database__PASSWD=$SERVICE_PASSWORD_POSTGRESQL + volumes: + - forgejo-data:/data + - forgejo-timezone:/etc/timezone:ro + - forgejo-localtime:/etc/localtime:ro + ports: + - 22222:22 + depends_on: + postgresql: + condition: service_healthy + healthcheck: + test: ["CMD", "curl", "-f", "http://127.0.0.1:3000"] + interval: 2s + timeout: 10s + retries: 15 + + postgresql: + image: postgres:16-alpine + volumes: + - forgejo-postgresql-data:/var/lib/postgresql/data + environment: + - POSTGRES_USER=${SERVICE_USER_POSTGRESQL} + - POSTGRES_PASSWORD=${SERVICE_PASSWORD_POSTGRESQL} + - POSTGRES_DB=${POSTGRESQL_DATABASE} + healthcheck: + test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"] + interval: 5s + timeout: 20s + retries: 10 diff --git a/templates/compose/forgejo-with-runner-with-mariadb.yaml b/templates/compose/forgejo-with-runner-with-mariadb.yaml new file mode 100644 index 000000000..a751ee284 --- /dev/null +++ b/templates/compose/forgejo-with-runner-with-mariadb.yaml @@ -0,0 +1,137 @@ +# documentation: https://forgejo.org/docs +# slogan: Forgejo is a self-hosted lightweight software forge. Easy to install and low maintenance, it just does the job. +# tags: version control, collaboration, code, hosting, lightweight, runner, mariadb, actions, cicd, ci +# logo: svgs/forgejo.svg + +services: + forgejo: + image: codeberg.org/forgejo/forgejo:7 + environment: + - SERVICE_FQDN_FORGEJO_3000 + - FORGEJO__server__ROOT_URL=${SERVICE_FQDN_FORGEJO} + - FORGEJO__migrations__ALLOWED_DOMAINS=${FORGEJO__migrations__ALLOWED_DOMAINS} + - FORGEJO__migrations__ALLOW_LOCALNETWORKS=${FORGEJO__migrations__ALLOW_LOCALNETWORKS-false} + - USER_UID=1000 + - USER_GID=1000 + - FORGEJO__database__DB_TYPE=mysql + - FORGEJO__database__HOST=mariadb + - FORGEJO__database__NAME=${MYSQL_DATABASE-forgejo} + - FORGEJO__database__USER=$SERVICE_USER_MYSQL + - FORGEJO__database__PASSWD=$SERVICE_PASSWORD_MYSQL + - RUNNER_SHARED_SECRET=${RUNNER_SHARED_SECRET-0000000000000000000000000000000000000000} + - FORGEJO__repository__ENABLE_PUSH_CREATE_USER=true + - FORGEJO__repository__DEFAULT_PUSH_CREATE_PRIVATE=false + - FORGEJO__repository__DEFAULT_REPO_UNITS=repo.code,repo.actions + volumes: + - forgejo-data:/data + - forgejo-timezone:/etc/timezone:ro + - forgejo-localtime:/etc/localtime:ro + ports: + - 22222:22 + depends_on: + mariadb: + condition: service_healthy + healthcheck: + test: ["CMD", "curl", "-f", "http://127.0.0.1:3000"] + interval: 2s + timeout: 10s + retries: 15 + command: >- + bash -c ' + /bin/s6-svscan /etc/s6 & + sleep 10 ; + su -c "forgejo forgejo-cli actions register --secret ${RUNNER_SHARED_SECRET}" git ; + sleep infinity + ' + + mariadb: + image: mariadb:11 + volumes: + - forgejo-mariadb-data:/var/lib/mysql + environment: + - MYSQL_USER=${SERVICE_USER_MYSQL} + - MYSQL_PASSWORD=${SERVICE_PASSWORD_MYSQL} + - MYSQL_DATABASE=${MYSQL_DATABASE} + - MYSQL_ROOT_PASSWORD=${SERVICE_PASSWORD_MYSQLROOT} + healthcheck: + test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] + interval: 5s + timeout: 20s + retries: 10 + + docker-in-docker: + image: docker:dind + hostname: docker + privileged: true + restart: 'unless-stopped' + healthcheck: + test: ["CMD", "pgrep", "dockerd"] + interval: 10s + timeout: 30s + retries: 10 + environment: + DOCKER_TLS_CERTDIR: /certs + DOCKER_HOST: docker-in-docker + volumes: + - forgejo-did-certs:/certs + + runner-register: + image: code.forgejo.org/forgejo/runner:3.5.0 + restart: 'no' + links: + - docker-in-docker + - forgejo + environment: + - DOCKER_HOST=tcp://docker-in-docker:2376 + - RUNNER_SHARED_SECRET=${RUNNER_SHARED_SECRET} + volumes: + - forgejo-runner-data:/data + - forgejo-timezone:/etc/timezone:ro + - forgejo-localtime:/etc/localtime:ro + healthcheck: + disable: true + user: 0:0 + command: >- + bash -ec ' + while : ; do + forgejo-runner create-runner-file --connect --instance http://forgejo:3000 --name runner --secret ${RUNNER_SHARED_SECRET} && break ; + sleep 1 ; + done ; + sed -i -e "s|\"labels\": null|\"labels\": [\"docker:docker://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 ; + exit 0 + ' + + runner: + image: code.forgejo.org/forgejo/runner:3.5.0 + links: + - docker-in-docker + - forgejo + depends_on: + docker-in-docker: + condition: service_started + environment: + - DOCKER_HOST=tcp://docker:2376 + - DOCKER_CERT_PATH=/certs/client + - DOCKER_TLS_VERIFY=1 + user: 1000:1000 + volumes: + - forgejo-runner-data:/data + - forgejo-did-certs:/certs + - forgejo-timezone:/etc/timezone:ro + - forgejo-localtime:/etc/localtime:ro + restart: 'unless-stopped' + healthcheck: + test: ["CMD", "pgrep", "forgejo-runner"] + interval: 10s + timeout: 30s + retries: 10 + command: >- + bash -c ' + while : ; do test -w .runner && forgejo-runner --config config.yml daemon ; sleep 1 ; done + ' \ No newline at end of file diff --git a/templates/compose/forgejo-with-runner-with-mysql.yaml b/templates/compose/forgejo-with-runner-with-mysql.yaml new file mode 100644 index 000000000..ccc33644f --- /dev/null +++ b/templates/compose/forgejo-with-runner-with-mysql.yaml @@ -0,0 +1,137 @@ +# documentation: https://forgejo.org/docs +# slogan: Forgejo is a self-hosted lightweight software forge. Easy to install and low maintenance, it just does the job. +# tags: version control, collaboration, code, hosting, lightweight, runner, mysql, actions, cicd, ci +# logo: svgs/forgejo.svg + +services: + forgejo: + image: codeberg.org/forgejo/forgejo:7 + environment: + - SERVICE_FQDN_FORGEJO_3000 + - FORGEJO__server__ROOT_URL=${SERVICE_FQDN_FORGEJO} + - FORGEJO__migrations__ALLOWED_DOMAINS=${FORGEJO__migrations__ALLOWED_DOMAINS} + - FORGEJO__migrations__ALLOW_LOCALNETWORKS=${FORGEJO__migrations__ALLOW_LOCALNETWORKS-false} + - USER_UID=1000 + - USER_GID=1000 + - FORGEJO__database__DB_TYPE=mysql + - FORGEJO__database__HOST=mysql + - FORGEJO__database__NAME=${MYSQL_DATABASE-forgejo} + - FORGEJO__database__USER=$SERVICE_USER_MYSQL + - FORGEJO__database__PASSWD=$SERVICE_PASSWORD_MYSQL + - RUNNER_SHARED_SECRET=${RUNNER_SHARED_SECRET-0000000000000000000000000000000000000000} + - FORGEJO__repository__ENABLE_PUSH_CREATE_USER=true + - FORGEJO__repository__DEFAULT_PUSH_CREATE_PRIVATE=false + - FORGEJO__repository__DEFAULT_REPO_UNITS=repo.code,repo.actions + volumes: + - forgejo-data:/data + - forgejo-timezone:/etc/timezone:ro + - forgejo-localtime:/etc/localtime:ro + ports: + - 22222:22 + depends_on: + mysql: + condition: service_healthy + healthcheck: + test: ["CMD", "curl", "-f", "http://127.0.0.1:3000"] + interval: 2s + timeout: 10s + retries: 15 + command: >- + bash -c ' + /bin/s6-svscan /etc/s6 & + sleep 10 ; + su -c "forgejo forgejo-cli actions register --secret ${RUNNER_SHARED_SECRET}" git ; + sleep infinity + ' + + mysql: + image: mysql:8 + volumes: + - forgejo-mysql-data:/var/lib/mysql + environment: + - MYSQL_USER=${SERVICE_USER_MYSQL} + - MYSQL_PASSWORD=${SERVICE_PASSWORD_MYSQL} + - MYSQL_DATABASE=${MYSQL_DATABASE} + - MYSQL_ROOT_PASSWORD=${SERVICE_PASSWORD_MYSQLROOT} + healthcheck: + test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1"] + interval: 5s + timeout: 20s + retries: 10 + + docker-in-docker: + image: docker:dind + hostname: docker + privileged: true + restart: 'unless-stopped' + healthcheck: + test: ["CMD", "pgrep", "dockerd"] + interval: 10s + timeout: 30s + retries: 10 + environment: + DOCKER_TLS_CERTDIR: /certs + DOCKER_HOST: docker-in-docker + volumes: + - forgejo-did-certs:/certs + + runner-register: + image: code.forgejo.org/forgejo/runner:3.5.0 + restart: 'no' + links: + - docker-in-docker + - forgejo + environment: + - DOCKER_HOST=tcp://docker-in-docker:2376 + - RUNNER_SHARED_SECRET=${RUNNER_SHARED_SECRET} + volumes: + - forgejo-runner-data:/data + - forgejo-timezone:/etc/timezone:ro + - forgejo-localtime:/etc/localtime:ro + healthcheck: + disable: true + user: 0:0 + command: >- + bash -ec ' + while : ; do + forgejo-runner create-runner-file --connect --instance http://forgejo:3000 --name runner --secret ${RUNNER_SHARED_SECRET} && break ; + sleep 1 ; + done ; + sed -i -e "s|\"labels\": null|\"labels\": [\"docker:docker://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 ; + exit 0 + ' + + runner: + image: code.forgejo.org/forgejo/runner:3.5.0 + links: + - docker-in-docker + - forgejo + depends_on: + docker-in-docker: + condition: service_started + environment: + - DOCKER_HOST=tcp://docker:2376 + - DOCKER_CERT_PATH=/certs/client + - DOCKER_TLS_VERIFY=1 + user: 1000:1000 + volumes: + - forgejo-runner-data:/data + - forgejo-did-certs:/certs + - forgejo-timezone:/etc/timezone:ro + - forgejo-localtime:/etc/localtime:ro + restart: 'unless-stopped' + healthcheck: + test: ["CMD", "pgrep", "forgejo-runner"] + interval: 10s + timeout: 30s + retries: 10 + command: >- + bash -c ' + while : ; do test -w .runner && forgejo-runner --config config.yml daemon ; sleep 1 ; done + ' \ No newline at end of file diff --git a/templates/compose/forgejo-with-runner-with-postgresql.yaml b/templates/compose/forgejo-with-runner-with-postgresql.yaml new file mode 100644 index 000000000..0b4dcd3fe --- /dev/null +++ b/templates/compose/forgejo-with-runner-with-postgresql.yaml @@ -0,0 +1,136 @@ +# documentation: https://forgejo.org/docs +# slogan: Forgejo is a self-hosted lightweight software forge. Easy to install and low maintenance, it just does the job. +# tags: version control, collaboration, code, hosting, lightweight, runner, postresql, actions, cicd, ci +# logo: svgs/forgejo.svg + +services: + forgejo: + image: codeberg.org/forgejo/forgejo:7 + environment: + - SERVICE_FQDN_FORGEJO_3000 + - FORGEJO__server__ROOT_URL=${SERVICE_FQDN_FORGEJO} + - FORGEJO__migrations__ALLOWED_DOMAINS=${FORGEJO__migrations__ALLOWED_DOMAINS} + - FORGEJO__migrations__ALLOW_LOCALNETWORKS=${FORGEJO__migrations__ALLOW_LOCALNETWORKS-false} + - USER_UID=1000 + - USER_GID=1000 + - FORGEJO__database__DB_TYPE=postgres + - FORGEJO__database__HOST=postgresql + - FORGEJO__database__NAME=${POSTGRESQL_DATABASE-forgejo} + - FORGEJO__database__USER=$SERVICE_USER_POSTGRESQL + - FORGEJO__database__PASSWD=$SERVICE_PASSWORD_POSTGRESQL + - RUNNER_SHARED_SECRET=${RUNNER_SHARED_SECRET-0000000000000000000000000000000000000000} + - FORGEJO__repository__ENABLE_PUSH_CREATE_USER=true + - FORGEJO__repository__DEFAULT_PUSH_CREATE_PRIVATE=false + - FORGEJO__repository__DEFAULT_REPO_UNITS=repo.code,repo.actions + volumes: + - forgejo-data:/data + - forgejo-timezone:/etc/timezone:ro + - forgejo-localtime:/etc/localtime:ro + ports: + - 22222:22 + depends_on: + postgresql: + condition: service_healthy + healthcheck: + test: ["CMD", "curl", "-f", "http://127.0.0.1:3000"] + interval: 2s + timeout: 10s + retries: 15 + command: >- + bash -c ' + /bin/s6-svscan /etc/s6 & + sleep 10 ; + su -c "forgejo forgejo-cli actions register --secret ${RUNNER_SHARED_SECRET}" git ; + sleep infinity + ' + + postgresql: + image: postgres:16-alpine + volumes: + - forgejo-postgresql-data:/var/lib/postgresql/data + environment: + - POSTGRES_USER=${SERVICE_USER_POSTGRESQL} + - POSTGRES_PASSWORD=${SERVICE_PASSWORD_POSTGRESQL} + - POSTGRES_DB=${POSTGRESQL_DATABASE} + healthcheck: + test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"] + interval: 5s + timeout: 20s + retries: 10 + + docker-in-docker: + image: docker:dind + hostname: docker + privileged: true + restart: 'unless-stopped' + healthcheck: + test: ["CMD", "pgrep", "dockerd"] + interval: 10s + timeout: 30s + retries: 10 + environment: + DOCKER_TLS_CERTDIR: /certs + DOCKER_HOST: docker-in-docker + volumes: + - forgejo-did-certs:/certs + + runner-register: + image: code.forgejo.org/forgejo/runner:3.5.0 + restart: 'no' + links: + - docker-in-docker + - forgejo + environment: + - DOCKER_HOST=tcp://docker-in-docker:2376 + - RUNNER_SHARED_SECRET=${RUNNER_SHARED_SECRET} + volumes: + - forgejo-runner-data:/data + - forgejo-timezone:/etc/timezone:ro + - forgejo-localtime:/etc/localtime:ro + healthcheck: + disable: true + user: 0:0 + command: >- + bash -ec ' + while : ; do + forgejo-runner create-runner-file --connect --instance http://forgejo:3000 --name runner --secret ${RUNNER_SHARED_SECRET} && break ; + sleep 1 ; + done ; + sed -i -e "s|\"labels\": null|\"labels\": [\"docker:docker://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 ; + exit 0 + ' + + runner: + image: code.forgejo.org/forgejo/runner:3.5.0 + links: + - docker-in-docker + - forgejo + depends_on: + docker-in-docker: + condition: service_started + environment: + - DOCKER_HOST=tcp://docker:2376 + - DOCKER_CERT_PATH=/certs/client + - DOCKER_TLS_VERIFY=1 + user: 1000:1000 + volumes: + - forgejo-runner-data:/data + - forgejo-did-certs:/certs + - forgejo-timezone:/etc/timezone:ro + - forgejo-localtime:/etc/localtime:ro + restart: 'unless-stopped' + healthcheck: + test: ["CMD", "pgrep", "forgejo-runner"] + interval: 10s + timeout: 30s + retries: 10 + command: >- + bash -c ' + while : ; do test -w .runner && forgejo-runner --config config.yml daemon ; sleep 1 ; done + ' \ No newline at end of file diff --git a/templates/compose/forgejo-with-runner.yaml b/templates/compose/forgejo-with-runner.yaml new file mode 100644 index 000000000..abcaa6e7e --- /dev/null +++ b/templates/compose/forgejo-with-runner.yaml @@ -0,0 +1,114 @@ +# documentation: https://forgejo.org/docs +# slogan: Forgejo is a self-hosted lightweight software forge. Easy to install and low maintenance, it just does the job. +# tags: version control, collaboration, code, hosting, lightweight, runner, actions, cicd, ci +# logo: svgs/forgejo.svg + +services: + forgejo: + image: codeberg.org/forgejo/forgejo:7 + environment: + - SERVICE_FQDN_FORGEJO_3000 + - FORGEJO__server__ROOT_URL=${SERVICE_FQDN_FORGEJO} + - FORGEJO__migrations__ALLOWED_DOMAINS=${FORGEJO__migrations__ALLOWED_DOMAINS} + - FORGEJO__migrations__ALLOW_LOCALNETWORKS=${FORGEJO__migrations__ALLOW_LOCALNETWORKS-false} + - USER_UID=1000 + - USER_GID=1000 + - RUNNER_SHARED_SECRET=${RUNNER_SHARED_SECRET-0000000000000000000000000000000000000000} + - FORGEJO__repository__ENABLE_PUSH_CREATE_USER=true + - FORGEJO__repository__DEFAULT_PUSH_CREATE_PRIVATE=false + - FORGEJO__repository__DEFAULT_REPO_UNITS=repo.code,repo.actions + volumes: + - forgejo-data:/data + - forgejo-timezone:/etc/timezone:ro + - forgejo-localtime:/etc/localtime:ro + ports: + - 22222:22 + healthcheck: + test: ["CMD", "curl", "-f", "http://127.0.0.1:3000"] + interval: 2s + timeout: 10s + retries: 15 + command: >- + bash -c ' + /bin/s6-svscan /etc/s6 & + sleep 10 ; + su -c "forgejo forgejo-cli actions register --secret ${RUNNER_SHARED_SECRET}" git ; + sleep infinity + ' + + docker-in-docker: + image: docker:dind + hostname: docker + privileged: true + restart: 'unless-stopped' + healthcheck: + test: ["CMD", "pgrep", "dockerd"] + interval: 10s + timeout: 30s + retries: 10 + environment: + DOCKER_TLS_CERTDIR: /certs + DOCKER_HOST: docker-in-docker + volumes: + - forgejo-did-certs:/certs + + runner-register: + image: code.forgejo.org/forgejo/runner:3.5.0 + restart: 'no' + links: + - docker-in-docker + - forgejo + environment: + - DOCKER_HOST=tcp://docker-in-docker:2376 + - RUNNER_SHARED_SECRET=${RUNNER_SHARED_SECRET} + volumes: + - forgejo-runner-data:/data + - forgejo-timezone:/etc/timezone:ro + - forgejo-localtime:/etc/localtime:ro + healthcheck: + disable: true + user: 0:0 + command: >- + bash -ec ' + while : ; do + forgejo-runner create-runner-file --connect --instance http://forgejo:3000 --name runner --secret ${RUNNER_SHARED_SECRET} && break ; + sleep 1 ; + done ; + sed -i -e "s|\"labels\": null|\"labels\": [\"docker:docker://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 ; + exit 0 + ' + + runner: + image: code.forgejo.org/forgejo/runner:3.5.0 + links: + - docker-in-docker + - forgejo + depends_on: + docker-in-docker: + condition: service_started + environment: + - DOCKER_HOST=tcp://docker:2376 + - DOCKER_CERT_PATH=/certs/client + - DOCKER_TLS_VERIFY=1 + user: 1000:1000 + volumes: + - forgejo-runner-data:/data + - forgejo-did-certs:/certs + - forgejo-timezone:/etc/timezone:ro + - forgejo-localtime:/etc/localtime:ro + restart: 'unless-stopped' + healthcheck: + test: ["CMD", "pgrep", "forgejo-runner"] + interval: 10s + timeout: 30s + retries: 10 + command: >- + bash -c ' + while : ; do test -w .runner && forgejo-runner --config config.yml daemon ; sleep 1 ; done + ' \ No newline at end of file diff --git a/templates/compose/forgejo.yaml b/templates/compose/forgejo.yaml new file mode 100644 index 000000000..bb6846679 --- /dev/null +++ b/templates/compose/forgejo.yaml @@ -0,0 +1,26 @@ +# documentation: https://forgejo.org/docs +# slogan: Forgejo is a self-hosted lightweight software forge. Easy to install and low maintenance, it just does the job. +# tags: version control, collaboration, code, hosting, lightweight +# logo: svgs/forgejo.svg + +services: + forgejo: + image: codeberg.org/forgejo/forgejo:7 + environment: + - SERVICE_FQDN_FORGEJO_3000 + - FORGEJO__server__ROOT_URL=${SERVICE_FQDN_FORGEJO} + - FORGEJO__migrations__ALLOWED_DOMAINS=${FORGEJO__migrations__ALLOWED_DOMAINS} + - FORGEJO__migrations__ALLOW_LOCALNETWORKS=${FORGEJO__migrations__ALLOW_LOCALNETWORKS-false} + - USER_UID=1000 + - USER_GID=1000 + ports: + - 22222:22 + volumes: + - forgejo-data:/data + - forgejo-timezone:/etc/timezone:ro + - forgejo-localtime:/etc/localtime:ro + healthcheck: + test: ["CMD", "curl", "-f", "http://127.0.0.1:3000"] + interval: 2s + timeout: 10s + retries: 15 \ No newline at end of file