79 lines
3.8 KiB
Markdown
79 lines
3.8 KiB
Markdown
# Forgejo
|
|
|
|
Wiki Cafe's configuration for the Forgejo deployment at git.wiki.cafe. Originally slimmed down from an `abra` [recipe](https://git.coopcloud.tech/coop-cloud/forgejo) by [Co-op Cloud](https://coopcloud.tech/).
|
|
|
|
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/Wiki%20Cafe%20Auth/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`. Its name is part of the callback URL, so renaming it means changing the redirect URI in Keycloak too. It was added with:
|
|
|
|
```
|
|
docker exec $(docker ps -q -f name=forgejo_app) forgejo admin auth add-oauth \
|
|
--name "Wiki Cafe Auth" --provider openidConnect --key forgejo --secret CLIENT_SECRET_HERE \
|
|
--auto-discover-url https://auth.wiki.cafe/realms/Wiki-Cafe/.well-known/openid-configuration \
|
|
--icon-url https://wiki.cafe/apple-touch-icon.png \
|
|
--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. Port 22 belongs to the host's sshd. Clone URLs look like `ssh://git@git.wiki.cafe:2222/OWNER/REPO.git`, the same shape as git.coopcloud.tech's. Port 2222 also has to be allowed in the Hetzner Cloud 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.
|