Christian Galo 0516ebd954 Slim down the Co-op Cloud forgejo recipe for git.wiki.cafe
Based on coop-cloud/forgejo 6.0.3+17.0.2-rootless. Single compose file with SQLite, settings and secret file URIs in app.ini, Caddy labels, and login only through the auth.wiki.cafe Operator Members group.
2026-11-27 00:14:50 +00:00

Forgejo

Wiki Cafe's configuration for the Forgejo deployment at git.wiki.cafe. Originally slimmed down from an abra recipe by Co-op Cloud.

Compared to the recipe:

  • One compose file. SQLite instead of a database container.
  • No docker-setup.sh override and no env var plumbing. Settings live in app.ini.tmpl, and secrets are read from files through Forgejo's *_URI = file: options.
  • Caddy labels instead of Traefik labels.
  • Login only through auth.wiki.cafe (Keycloak). Local password login and sign-up are off.

Deploying the app with Docker Swarm

Set the environment variables from the .env file during the shell session.

set -a && source .env && set +a

Set the secrets.

I=codeberg.org/forgejo/forgejo:17.0.2-rootless
docker run --rm $I forgejo generate secret SECRET_KEY | docker secret create forgejo_secret_key -
docker run --rm $I forgejo generate secret INTERNAL_TOKEN | docker secret create forgejo_internal_token -
docker run --rm $I forgejo generate secret JWT_SECRET | docker secret create forgejo_jwt_secret -
printf "SMTP_PASSWORD_HERE" | docker secret create forgejo_smtp_password -

The SMTP password is the mailbox.org app password for mail@wiki.cafe.

Let Caddy issue a certificate for the domain. The TLS ask (caddy_ask) only approves names that have a directory in the fedwiki_data volume.

docker exec -u node $(docker ps -q -f name=caddy_ask) mkdir /data/git.wiki.cafe

Deploy using the -c flag to specify one or multiple compose files.

docker stack deploy forgejo --detach=true -c compose.yaml

Changing app.ini

Swarm configs can't be changed in place. After editing app.ini.tmpl, bump the version in the config name in compose.yaml (${STACK_NAME}_app_ini_v1 to _v2) and redeploy.

Login through auth.wiki.cafe

The Keycloak side is the forgejo client in the Wiki-Cafe realm:

  • Redirect URI https://git.wiki.cafe/user/oauth2/auth.wiki.cafe/callback
  • A groups protocol mapper (Group Membership, full path off), added to the ID token, access token and userinfo.

The Forgejo side is a login source stored in the database, not in app.ini. It was added with:

docker exec $(docker ps -q -f name=forgejo_app) forgejo admin auth add-oauth \
  --name auth.wiki.cafe --provider openidConnect --key forgejo --secret CLIENT_SECRET_HERE \
  --auto-discover-url https://auth.wiki.cafe/realms/Wiki-Cafe/.well-known/openid-configuration \
  --scopes email --scopes profile --skip-local-2fa \
  --group-claim-name groups --admin-group "Operator Members" \
  --required-claim-name groups --required-claim-value "Operator Members"

Only members of the Keycloak group Operator Members can log in, and they are site admins. Admin rights follow the group on every login. To let more people in, change the required claim value (Site Administration, Authentication Sources, or forgejo admin auth update-oauth --id 1).

SSH

Forgejo runs its own SSH server on port 2222, published in host mode. Clone URLs look like ssh://git@git.wiki.cafe:2222/OWNER/REPO.git. Port 2222 also has to be allowed in the Hetzner firewall.

Miscellaneous notes

  • chmod: /var/lib/gitea/custom: Operation not permitted at startup is harmless. Docker creates custom/conf as root when it mounts app.ini.
  • Backupbot copies the data volume while Forgejo is running. There is no SQLite dump hook yet.
  • There is no Anubis in front of it. If scrapers become a problem, see the recipe's compose.anubis.yml.
  • The built-in SSH server only has an RSA host key.
S
Description
Configuration for Swarm deployment of Forgejo (git.wiki.cafe).
Readme GPL-3.0
46 KiB
Languages
Go Template 100%