Repositorios git (forgejo)
Repositorios git en una caja Self Host Wizard: la pieza forgejo, en git.<dominio de apps>, ingreso oidc, límite de memoria 280 MB.
De un vistazo
| Dato | Valor |
|---|---|
| Dirección | https://git.<dominio de apps> |
| Ingreso | oidc: OpenID Connect con Authelia: el ingreso de la oficina sirve también acá |
| Límite de memoria | 280 MB (ram_mb: pico medido × 1,3) |
| Base de datos | ninguna compartida: guarda sus datos en THX_DATA |
| Necesita | lldap, authelia, stalwart |
| La necesitan | nada |
| Contenedores | forgejo |
Imagen: forgejo | codeberg.org/forgejo/forgejo:15.0.12-rootless@sha256:b670d7724274e1d5c7801b76017b7267e6e5432aa4fe8bed49f781d09476b9dd |
| Puertos públicos | 2222/tcp |
| Script de configuración al arrancar | scripts/post-up.sh, diario |
| Licencia (según el README) | GPL-3.0-or-later |
| Proyecto original (según el README) | https://forgejo.org |
Cómo activarla
thx enable agrega forgejo y todo lo que necesita al estado de la caja; después thx apply la instala. Las apps se aplican recién cuando site_domain está definido.
sudo thx enable forgejo
sudo thx apply
Notas técnicas (pieces/forgejo/README.md)
Las notas técnicas de cada pieza están en inglés, tal como están en el repositorio.
Upstream: Forgejo 15.0.12 (LTS line), GPL-3.0-or-later, image
codeberg.org/forgejo/forgejo:15.0.12-rootless, pinned by multi-arch index digest
(docker buildx imagetools inspect lists linux/amd64 and linux/arm64). We ship compose and
config only. 15 is the long-term-support line (17.0.2 is the newest; 15 gets fixes for longer and
has everything used here).
Served at https://git.<apps_domain>; git over ssh on public port 2222.
What it does on the box
- One container, SQLite (WAL) in
THX_DATA, built-in ssh server (the rootless image has no OpenSSH). The image runs as uid 1000, soTHX_DATAmust be owned by1000:1000(data_ownerin piece.toml). - Login only through Authelia (OpenID Connect, source name
authelia). First login creates the account (username =preferred_username= LLDAP uid, email from LLDAP). No local sign-up, no password form (ENABLE_INTERNAL_SIGNIN=false). Anonymous visitors see nothing (REQUIRE_SIGNIN_VIEW), new repositories are private. - Login is automatic. Forgejo has no setting to skip its login page, so piece.toml's
[oidc] login_page/login_starthas Caddy send a person who arrives at/user/loginfrom outside Forgejo (a link, a bookmark, Forgejo's own redirect from/) straight on to/user/oauth2/authelia, keepingredirect_to. Someone already signed in to the office lands inside without a click; anyone else signs in at Authelia once and comes back. After signing out of Forgejo the login page stays (the request comes from Forgejo itself), and a failed sign-in shows Forgejo's error instead of looping (one automatic try a minute). Companies → organizations.
post_upcreates one organization per org inTHX_ORGS, each with amembersteam (write on all repos, may create repos). The login source maps groups on every login, and removes memberships when the group goes away:LLDAP group Forgejo adminssite administrator org-<org>team membersof organization<org>team-<org>-adminsteam Ownersof organization<org>(org settings, runners, secrets)Organizations are never deleted by thx; an org removed from state just stops being mapped. Other
team-<org>-<team>groups are not mapped yet (one line each in the map if wanted).- A local service account
thx-admin(password =THX_SECRET_ADMIN_PASSWORD, only on the box) exists forpost_up's API calls and owns every organization it created. It is also the break-glass path while Authelia is down: the API (basic auth) andforgejo adminin the container, not the web UI. - Packages and the container registry are on (
git.<apps_domain>/v2/,/api/packages/<org>/…). - Mail through
THX_SMTP_HOST:THX_SMTP_PORTfromTHX_MAIL_FROM(certificate not checked on the private piece network: stalwart's certificate is not for the namestalwart). - Actions are on, but no runner runs on the box. The box has 2 cores shared with mail; a CI job would starve it. Each company runs its runner on its own machine (below).
Using it
- https:
git clone https://git.<apps_domain>/<org>/<repo>.git. Accounts have no password (they log in through Authelia), so git over https uses a personal access token as the password: Settings → Applications → Generate new token, scope repository: read and write. - ssh: add a key in Settings → SSH / GPG keys, then
git clone ssh://git@git.<apps_domain>:2222/<org>/<repo>.git.
Registering a CI runner on another machine
Forgejo Runner 13 no longer uses register; the runner is created in Forgejo and the runner
machine gets its UUID and token. This is the exact path the test runs.
- In Forgejo, an org owner (LLDAP group
team-<org>-admins) opens Organization → Settings → Actions → Runners and creates a runner, or calls the API:curl -X POST -H "Authorization: token <PAT>" -H 'Content-Type: application/json' -d '{"name":"office-pc"}' https://git.<apps_domain>/api/v1/orgs/<org>/actions/runners→{"uuid": "…", "token": "…"}. Keep the token secret. On the runner machine (any Linux PC or VM with Docker), write
config.yml:runner: file: /data/.runner capacity: 1 labels: ["docker:docker://node:22-bookworm"] server: connections: office: url: https://git.<apps_domain>/ uuid: <uuid> token: <token>Run it (image pinned like everything else; check the digest with
docker buildx imagetools inspect data.forgejo.org/forgejo/runner:13.2.2):docker run -d --name forgejo-runner --restart unless-stopped \ -v "$PWD/config.yml:/config.yml:ro" -v runner-data:/data \ -v /var/run/docker.sock:/var/run/docker.sock --group-add "$(stat -c %g /var/run/docker.sock)" \ data.forgejo.org/forgejo/runner:13.2.2 forgejo-runner daemon -c /config.ymlJobs with
runs-on: dockerthen run in throwaway containers on that machine. Mounting the Docker socket gives jobs root on that machine: use a machine dedicated to CI.- Workflows live in
.forgejo/workflows/*.yml(GitHub Actions syntax).
The test proves steps 1–2 and a job run end to end, with a self-hosted:host label (job steps
run inside the runner container, no Docker needed). The docker:// label variant above is the
upstream-documented way and was not run here (it needs Docker inside the test).
Mirroring to GitHub
Per repository: Settings → Repository → Mirror settings → Push mirror. Remote URL
https://github.com/<owner>/<repo>.git, username = GitHub user, password = a GitHub fine-grained
token with Contents: read and write on that repo; tick Sync when commits are pushed. Forgejo
then pushes every branch and tag to GitHub. To bring a GitHub repo in, use New migration →
GitHub (one-off copy, or a pull mirror that re-fetches on an interval).
Measured (dev PC, amd64, test.sh)
RAM: three runs peaked at 187, 214 and 134 MiB (docker stats, which includes page cache)
over the whole test (login, token, repo, https + ssh push, package upload, Actions job, mail).
ram_mb = 280 (214 × 1.3 = 278). Large pushes, git gc on big
repos and the code/issue indexers can exceed this; raise it from a measurement if it OOMs.
Test
HEAVY_CLASS=check ~/.cache/run-heavy.sh 4G pieces/forgejo/test.sh — throwaway LLDAP, Authelia,
Caddy (self-signed CA), a mail catcher answering as stalwart. Proves: post_up converges and a
second run changes nothing; alice (LLDAP, org-acme) logs in via OIDC and is auto-registered;
she makes a token in the web UI, is in org acme only, creates acme/hello (and cannot create in
beta), pushes over https through Caddy/TLS and over ssh; generic package upload; /v2/ answers;
boss (admins) is a site admin and, as team-acme-admins, creates an org runner; a runner
container connects and runs a pushed workflow to success; a mail reaches the catcher.
Prints PASS forgejo ram_peak_mb=<n>.
testkit/thxtest.py is the shared throwaway-SSO harness for every piece test of this lane.
Known gaps
- OIDC users have no password, so https git needs a token (as on GitHub). LDAP basic auth for git would need a second login source per user; not done.
team-<org>-<team>groups other than-adminsare not mapped to Forgejo teams.- No runner on the box by design.