showcase
- v0.2.4
- 37 commits
- 1 branch
- 6 tags
- updated
- CI 2/2
README.md
6.4 KB · 167 lines
1# showcase23A small, read-only public view of selected Gitea repos, served at4[code.danieldaum.net](https://code.danieldaum.net) and styled as part of5danieldaum.net. One Go binary6rebuilds static HTML from Gitea on a timer, serves it, and passes `git clone`7and `docker pull` through to Gitea. The public side can't write, log in, or8reach Gitea's UI or API.910It talks to Gitea anonymously, so it can only ever see public data. Only the11repos and images listed in `config.json` are rendered or proxied.1213## Develop1415Needs [mise](https://mise.jdx.dev) and [just](https://just.systems).1617```sh18mise install # Go version pinned in mise.toml19just # list commands20just test # run tests21just lint # gofmt + go vet22just golden # rewrite golden files after an intended output change23just render # render the site once into ./out from ./config.json24just demo # render the test fixtures and serve them on localhost:800025just run # build from real Gitea every 10 min and serve on localhost:800026```2728## Configure2930`config.json` (mounted read-only at `/config.json` in the container):3132```json33{34 "gitea_url": "https://git.danieldaum.net",35 "user": "daniel",36 "site_url": "https://code.danieldaum.net",37 "base_path": "",38 "repos": ["repo-a", "repo-b"],39 "images": ["repo-a"],40 "featured": ["repo-a"],41 "max_commits": 50,42 "theme": "moss",43 "trusted_proxies": ["100.64.0.10"]44}45```4647`featured` (optional) picks up to six repos for the profile, in order.48Without it, the six most recently updated are shown. Every repo is listed49at `/repos/`. `base_path` (optional, like `/projects`) serves the pages50under one path, for danieldaum.net/projects; clone, `go get` and51`docker pull` stay at the root of `site_url`.5253## Deploy5455Running it at code.danieldaum.net, moving Gitea to the tailnet and serving56it at danieldaum.net/projects are in [deploy/README.md](deploy/README.md).57`just image` builds an image for this machine only, to try it locally.5859### Release a version6061A release is a git tag `v<version>`, an image62`code.aardvark-halibut.ts.net/daniel/showcase:<version>` (also tagged `latest`, in Gitea's63registry on the tailnet) and a Gitea release. Versions follow semver: a fix bumps the patch (0.2.0 →640.2.1), a feature the minor (0.2.0 → 0.3.0). The examples release 0.2.1.6566You commit, tag and deploy. Pushing the tag starts67[`.gitea/workflows/release.yml`](.gitea/workflows/release.yml), which does68the rest.69701. **Check and push the commit.**7172 ```sh73 just lint && just test74 git log --oneline v0.2.0..HEAD # what goes into the release75 git push origin main76 ```77782. **Tag it and push the tag** (signed, since `tag.gpgsign` is on).7980 ```sh81 git tag -s v0.2.1 -m v0.2.182 git push origin v0.2.1 # starts the release workflow83 ```8485 Tagged the wrong commit? Before pushing, `git tag -d v0.2.1` and tag86 again. Once pushed, leave it and release 0.2.2.87883. **The workflow** (Gitea → showcase → Actions) builds the image for the89 server (linux/amd64), pushes it as `0.2.1` and `latest`, and creates90 the Gitea release `v0.2.1` with the image digest and the commits since91 `v0.2.0`.9293 To run it by hand, for example after a failed run: Actions → release →94 Run workflow, on `main`, with the tag (`v0.2.1`). It builds that tag's95 code with the workflow on `main`, so a fixed workflow works for an96 older tag, and it updates the tag's release with the new digest.97984. **Deploy.** Pin the digest from the release notes in99 `deploy/compose.yaml` (the `image:` line and the version in the comment100 above it) and commit that. Copy `compose.yaml` to the server and, next101 to it and `config.json`:102103 ```sh104 docker compose pull && docker compose up -d105 curl -s 127.0.0.1:8080/healthz # "ok" once a build is live106 ```107108**Once, before the first run:** enable Actions for the repo and add a repo109secret `REGISTRY_TOKEN` (Settings → Actions → Secrets): a Gitea access110token with `write:package`. That's the only token to make: `GITEA_TOKEN`,111which writes the release, is made by Gitea for each run. The runner needs112Docker (act_runner gives jobs the host's Docker by default).113114**Without CI**, from the Mac, after step 2:115116```sh117docker login code.aardvark-halibut.ts.net # once; a Gitea token with write:package118just release 0.2.1 # same image and tags; no Gitea release119crane digest code.aardvark-halibut.ts.net/daniel/showcase:0.2.1120```121122Use one or the other for a version: a rebuild gets a new digest.123124### Container125126The container runs as uid 10001 with a read-only root filesystem, no127capabilities and `no-new-privileges`. Only `/data` is writable: git mirrors128and site builds. It listens on plain HTTP `:8080` behind a reverse proxy129that terminates TLS.130131## Layout132133```134cmd/showcase/ entrypoint135internal/config/ config.json loading and validation136internal/gitea/ anonymous Gitea API client137internal/gitx/ git CLI wrappers138internal/build/ build loop and rendering pipeline139internal/render/ templates, markdown, highlighting, heatmap SVG140internal/server/ router, static files, git + registry proxy141web/ embedded templates and static assets142testdata/ sample Gitea JSON and golden output143docs/ spec and design decisions144Dockerfile golang build stage, alpine + git runtime, pinned by digest145deploy/ compose, production config, saturn patch and runbook146.gitea/workflows/ release: builds and pushes the image on a version tag147```148149## Docs150151- [docs/spec.md](docs/spec.md): what this is and isn't, the security rules152 and the build order.153- [docs/decisions.md](docs/decisions.md): choices made while building.154- [docs/theme.md](docs/theme.md): how the look follows danieldaum.net.155- [docs/security.md](docs/security.md): each security rule mapped to code and tests.156157## Licences158159Styles and palettes come from [saturn](https://tangled.org/danieldaum.net/saturn)160(danieldaum.net, MIT), which builds on Flexoki (MIT,161[stephango.com/flexoki](https://stephango.com/flexoki)). Geist Mono and Geist162Pixel are under the SIL Open Font License. Icons are the ones Gitea163uses: file icons from164[material-icon-theme](https://github.com/material-extensions/vscode-material-icon-theme)165(MIT) and UI icons from [Octicons](https://github.com/primer/octicons) (MIT,166GitHub). The licence files are in `web/static/fonts/`,167`web/static/icons/material/` and `web/static/icons/octicons/`.