A minimal self-hosted git browser on Rust axum: bare repos rendered as a website with commits, diffs, syntax-highlighted blobs, atom feeds, and clone over HTTPS.
axumdockergitgit-browsergitoxidegixrustself-hosted
1CARGO ?= $(HOME)/.cargo/bin/cargo
2PORT ?= 8000
3
4# In dev the bare repos at /srv/git live on the production server, not here.
5# Use ./fixtures/git as the local repo root; `make seed` populates it so
6# `make run` has something to show on the landing page.
7REPOS_REPO_ROOT ?= $(CURDIR)/fixtures/git
8
9.DEFAULT_GOAL := run
10.PHONY: run build start clean push seed seed-reset
11
12# Dev: Vite watch + cargo run concurrently. Both die on Ctrl+C.
13# Seeding is opt-in (run `make seed` once); a fresh checkout shows an empty
14# repo list until you do.
15run: frontend/node_modules dist/.vite/manifest.json
16 @trap 'kill 0' EXIT INT TERM; \
17 (cd frontend && bun run dev) & \
18 PORT=$(PORT) REPOS_REPO_ROOT=$(REPOS_REPO_ROOT) $(CARGO) run
19
20# Production build (Vite assets + release binary)
21build: frontend/node_modules
22 cd frontend && bun run build
23 $(CARGO) build --release
24
25# Run the release binary (after `make build`)
26start:
27 PORT=$(PORT) ./target/release/repos
28
29# Wipe regenerable output. Leaves fixtures/ alone so `make run` after `make
30# clean` doesn't blow away your seeded repos.
31clean:
32 rm -rf target dist frontend/node_modules
33
34push:
35 git remote | xargs -I R git push R master
36
37# Synthesize a handful of fake-but-realistic bare repos under fixtures/git/
38# via the `seed` bin. Idempotent: existing repo dirs are left alone, so
39# re-running is cheap. Override defaults inline, e.g. `make seed COUNT=12
40# DAYS=45 SEED=42`. See src/bin/seed.rs for the archetypes and patches.
41COUNT ?=
42DAYS ?=
43SEED ?=
44SEED_ARGS = $(if $(COUNT),--count $(COUNT)) $(if $(DAYS),--days $(DAYS)) $(if $(SEED),--seed $(SEED))
45
46seed:
47 $(CARGO) run --quiet --bin seed -- $(SEED_ARGS)
48
49# Wipe and regenerate from scratch. Use after editing seed.rs or when you
50# want a different deterministic set (pair with SEED=<n>).
51seed-reset:
52 $(CARGO) run --quiet --bin seed -- --reset $(SEED_ARGS)
53
54frontend/node_modules:
55 cd frontend && bun install
56
57dist/.vite/manifest.json: frontend/node_modules
58 cd frontend && bun run build