penguin/flatgit

flatgit showcase

summary

default branchmaster
default commit351aa29cde84023a850bad9d3ede7f44a18b85e3

recent commits

commitdateauthorsubject
351aa292026-07-04T13:01:36Z斟酌 鵬兄Added render archive
b4e84062026-06-28T11:32:20Z斟酌 鵬兄Update demo location
9cb44b02026-06-28T02:42:49Z斟酌 鵬兄Added liveness test

files

pathsize
.github/workflows/ci.yml2000
.gitignore87
LICENSE1070
Makefile1522
README.md3302
build.env56
cmd/flatgit/main.go5775
dockerfiles/github.Dockerfile1114
dockerfiles/runtime.Dockerfile977
examples/tinyproxy.json507
go.mod274
go.sum845
internal/buildinfo/buildinfo_gen.go150
internal/config/config.go3941
internal/config/config_test.go482
internal/gitcmd/gitcmd.go4217
internal/jobqueue/jobqueue.go1565
internal/render/archive.go897
internal/render/manifest.go3168
internal/render/markdown.go986
internal/render/render.go11109
internal/render/rtree.go3638
internal/render/templates.go5045
internal/server/server.go3147
internal/webhook/webhook.go4563
resources/flatgit.chart/Chart.yaml139
resources/flatgit.chart/templates/_helpers.tpl580
resources/flatgit.chart/templates/configmap.yaml1124
resources/flatgit.chart/templates/deployment.yaml2592
resources/flatgit.chart/templates/httproutes.yaml833
resources/flatgit.chart/templates/pvc.yaml464
resources/flatgit.chart/templates/secret.yaml220
resources/flatgit.chart/templates/service.yaml393
resources/flatgit.chart/values.yaml1214
resources/robots.txt81

flatgit

A static Git web generator with webhook-driven updates and an optional built-in file server.

The main goal for this projects is to make bots and agents's life easier. Also to relief the stress on them crawling the forge platform interfaces.

Each repository have a manifest.json that lists all available navigation paths.

Demo

Install

via helm

helm show values ./resources/flatgit.chart/ > values.yaml
edit values.yaml
helm upgrade --install -n <NAMESPACE> <RELEASE_NAME> ./resources/flatgit.chart/ -f values.yaml

Philosophy

Git repo in, static browsable site out.

webhook -> git clone/fetch --mirror -> render HTML + JSON -> serve static files

It currently shells out to the real git binary.

Since Git already knows how to deal with packed refs, tags, bare repositories, weird histories, and future compatibility. The main focus is on rendering.

HTML should be served by proper http server if possible. The built-in server is fine but basic.

Current status

Build

make clean build

Config

See examples/tinyproxy.json:

{
  "addr": ":8080",
  "data_dir": "/var/lib/flatgit",
  "webhook": {
    "secret": "change-me"
  },
  "git": {
    "command": "git",
    "clone_timeout": "2m",
    "fetch_timeout": "2m"
  },
  "render": {
    "workers": 2,
    "max_commits": 500
  },
  "repos": [
    {
      "owner": "penguin",
      "name": "test-repo",
      "url": "http://gitea-http.gitea.svc.cluster.local:3000/penguin/test-repo.git",
      "default_branch": "main"
    }
  ]
}

Derived paths:

/var/lib/flatgit/repos/penguin_test-repo.git
/var/lib/flatgit/www/penguin_test-repo

Commands

Render all configured repos:

flatgit render -c examples/flatgit.json

Render one repo:

flatgit render -c examples/flatgit.json -repo penguin_test-repo

Serve an already-rendered web root:

flatgit serve -root /var/lib/flatgit/www -addr :8080

Run the daemon:

flatgit daemon -c examples/flatgit.json

The daemon serves:

/                       static web root
/healthz                health check
/webhook/gitea          Gitea webhook endpoint
/webhook/github         GitHub webhook endpoint

Webhook signature

If webhook.secret is non-empty, the handler accepts either:

The HMAC is SHA-256 over the raw request body.

TODO