Krolyxon
Commit 3cb9866

ferreniumREADME.md

141 lines · 4.7 KB · Markdown

1# Ferrenium
2
3A read-only Git repository browser, like cgit, as a single Rust daemon. It
4serves every bare repository under one directory and keeps no state on disk.
5
6Pages: repo index, summary + README, tree, file (highlighted), raw, log
7(path filter, message search), commit + diff, `.patch`, blame, refs, file
8finder, `.tar.gz`/`.zip` snapshots, Atom feed. `git clone` over HTTPS
9(read-only).
10
11## Install
12
13On a Linux host with systemd (x86_64 or aarch64, glibc 2.28+):
14
15```sh
16curl -fsSL https://github.com/krolyxon/ferrenium/releases/latest/download/install.sh | sudo FERRENIUM_DOMAIN=git.example.com sh
17```
18
19This:
20
21- downloads the latest release binary, verifies its checksum and installs it to `/usr/local/bin/ferrenium`
22- creates the `git` user if it doesn't exist (home `/home/git`, shell `git-shell`)
23- writes `/etc/ferrenium/ferrenium.toml` (never overwritten on later runs)
24- installs `/etc/systemd/system/ferrenium.service` and runs `systemctl enable --now ferrenium`
25
26Variables: `FERRENIUM_DOMAIN` (fills `base_url` and clone URLs in a new
27config), `FERRENIUM_USER` (default `git`), `FERRENIUM_VERSION` (e.g.
28`v0.1.0`, default latest).
29
30Run the same command again to upgrade: it replaces the binary and unit
31and restarts the service. To remove it: `… | sudo sh -s -- --uninstall`.
32This keeps `/etc/ferrenium` and the repositories.
33
34### The service
35
36It's a normal system service. The unit has `User=git`, so systemd starts it
37as the repo owner. You don't need `su git` or `systemctl --user`.
38
39```sh
40sudo systemctl status ferrenium
41sudo systemctl reload ferrenium # after editing the config
42sudo journalctl -u ferrenium -f
43sudo systemctl edit ferrenium # overrides; survive upgrades
44```
45
46The unit is sandboxed: the filesystem is read-only, there are no
47capabilities, a syscall filter applies, and only localhost may connect.
48
49### Reverse proxy
50
51Ferrenium listens on `127.0.0.1:8080` (plain HTTP/1.1). Caddy:
52
53```caddy
54git.example.com {
55 reverse_proxy 127.0.0.1:8080
56}
57```
58
59If Caddy runs in Docker, use `network_mode: host` so it can reach
60`127.0.0.1`.
61
62### Repositories
63
64Put bare repositories anywhere under `/home/git` (up to 3 levels deep).
65Ferrenium picks up new repos and pushes within about a second.
66
67```sh
68sudo -u git git init --bare /home/git/project.git
69git push git@git.example.com:project.git main # after adding your key to /home/git/.ssh/authorized_keys
70```
71
72## Configuration
73
74Edit `/etc/ferrenium/ferrenium.toml`. Every key is optional and unknown
75keys are errors. The file lists all keys with their defaults
76(`ferrenium example config` prints the same). To validate the config and
77list the repositories it finds:
78
79```sh
80ferrenium check --config /etc/ferrenium/ferrenium.toml
81```
82
83`listen`, `base_path`, `compression`, `cache.size_mb` and the `limits.*_parallel`/`max_requests`
84settings need a restart; everything else applies on reload.
85
86Per-repository metadata comes from the first source that sets it:
87
881. `[[repo]]` in the config (`name`, `description`, `section`, `owner`, `hidden`, `readme`, `default_branch`)
892. the repo's git config: `ferrenium.{description,owner,section,hidden,readme}`, or the gitweb/cgit keys
903. the repo's `description` file
91
92```sh
93sudo -u git git -C /home/git/secret.git config ferrenium.hidden true
94```
95
96### Limits
97
98Defaults are sized for a small VPS:
99
100| Key | Default | |
101|---|---|---|
102| `limits.git_parallel` | CPUs, max 8 | concurrent git work |
103| `limits.heavy_parallel` | 2 | concurrent blame / archive / clone / log search |
104| `limits.heavy_wait_secs` | 10 | queue time for those before `503` |
105| `limits.max_requests` | 512 | in-flight requests before `503` |
106| `limits.request_timeout_secs` | 30 | until the response starts |
107| `limits.diff_files` / `diff_lines` | 300 / 10000 | larger diffs are truncated |
108| `ui.max_blob_kb` / `max_highlight_kb` | 1024 / 256 | larger files: raw link / no highlighting |
109| `cache.size_mb` | 64 | in-memory cache |
110
111`/robots.txt` keeps crawlers off the expensive pages. Memory use at idle is
112about 10 MB.
113
114## Building from source
115
116Requires Rust 1.89+.
117
118```sh
119cargo build --release # target/release/ferrenium
120ferrenium example config|systemd|caddy
121```
122
123## Development
124
125```sh
126cargo test # needs the git CLI
127cargo test --release
128cargo clippy --all-targets -- -D warnings
129cargo run -- serve --config dev.toml
130tools/gen-languages/gen.py # regenerate the Linguist language table
131```
132
133To release: bump `version` in `Cargo.toml`, commit, then push a `vX.Y.Z` tag.
134The `release` workflow tests, builds x86_64 and aarch64 binaries, and
135publishes them with `install.sh` and `SHA256SUMS`.
136
137## License
138
139GPL-3.0 (see `LICENSE`). Bundled fonts (Doto, Space Grotesk, Space Mono)
140are licensed under the OFL; see `assets/fonts/OFL.txt`. Icons come from
141Lucide (ISC license).