Documents
showcase
A small, read-only public view of selected Gitea repos, served at
code.danieldaum.net and styled as part of
danieldaum.net. One Go binary
rebuilds static HTML from Gitea on a timer, serves it, and passes git clone
and docker pull through to Gitea. The public side can't write, log in, or
reach Gitea's UI or API.
It talks to Gitea anonymously, so it can only ever see public data. Only the
repos and images listed in config.json are rendered or proxied.
Develop
mise install # Go version pinned in mise.toml
just # list commands
just test # run tests
just lint # gofmt + go vet
just golden # rewrite golden files after an intended output change
just render # render the site once into ./out from ./config.json
just demo # render the test fixtures and serve them on localhost:8000
just run # build from real Gitea every 10 min and serve on localhost:8000
Configure
config.json (mounted read-only at /config.json in the container):
{
"gitea_url": "https://git.danieldaum.net",
"user": "daniel",
"site_url": "https://code.danieldaum.net",
"base_path": "",
"repos": ["repo-a", "repo-b"],
"images": ["repo-a"],
"featured": ["repo-a"],
"max_commits": 50,
"theme": "moss",
"trusted_proxies": ["100.64.0.10"]
}
featured (optional) picks up to six repos for the profile, in order.
Without it, the six most recently updated are shown. Every repo is listed
at /repos/. base_path (optional, like /projects) serves the pages
under one path, for danieldaum.net/projects; clone, go get and
docker pull stay at the root of site_url.
Deploy
Running it at code.danieldaum.net, moving Gitea to the tailnet and serving
it at danieldaum.net/projects are in deploy/README.md.
just image builds an image for this machine only, to try it locally.
Release a version
A release is a git tag v<version>, an image
code.aardvark-halibut.ts.net/daniel/showcase:<version> (also tagged latest, in Gitea's
registry on the tailnet) and a Gitea release. Versions follow semver: a fix bumps the patch (0.2.0 →
0.2.1), a feature the minor (0.2.0 → 0.3.0). The examples release 0.2.1.
You commit, tag and deploy. Pushing the tag starts
.gitea/workflows/release.yml, which does
the rest.
-
Check and push the commit.
just lint && just test git log --oneline v0.2.0..HEAD # what goes into the release git push origin main -
Tag it and push the tag (signed, since
tag.gpgsignis on).git tag -s v0.2.1 -m v0.2.1 git push origin v0.2.1 # starts the release workflowTagged the wrong commit? Before pushing,
git tag -d v0.2.1and tag again. Once pushed, leave it and release 0.2.2. -
The workflow (Gitea → showcase → Actions) builds the image for the server (linux/amd64), pushes it as
0.2.1andlatest, and creates the Gitea releasev0.2.1with the image digest and the commits sincev0.2.0.To run it by hand, for example after a failed run: Actions → release → Run workflow, on
main, with the tag (v0.2.1). It builds that tag's code with the workflow onmain, so a fixed workflow works for an older tag, and it updates the tag's release with the new digest. -
Deploy. Pin the digest from the release notes in
deploy/compose.yaml(theimage:line and the version in the comment above it) and commit that. Copycompose.yamlto the server and, next to it andconfig.json:docker compose pull && docker compose up -d curl -s 127.0.0.1:8080/healthz # "ok" once a build is live
Once, before the first run: enable Actions for the repo and add a repo
secret REGISTRY_TOKEN (Settings → Actions → Secrets): a Gitea access
token with write:package. That's the only token to make: GITEA_TOKEN,
which writes the release, is made by Gitea for each run. The runner needs
Docker (act_runner gives jobs the host's Docker by default).
Without CI, from the Mac, after step 2:
docker login code.aardvark-halibut.ts.net # once; a Gitea token with write:package
just release 0.2.1 # same image and tags; no Gitea release
crane digest code.aardvark-halibut.ts.net/daniel/showcase:0.2.1
Use one or the other for a version: a rebuild gets a new digest.
Container
The container runs as uid 10001 with a read-only root filesystem, no
capabilities and no-new-privileges. Only /data is writable: git mirrors
and site builds. It listens on plain HTTP :8080 behind a reverse proxy
that terminates TLS.
Layout
cmd/showcase/ entrypoint
internal/config/ config.json loading and validation
internal/gitea/ anonymous Gitea API client
internal/gitx/ git CLI wrappers
internal/build/ build loop and rendering pipeline
internal/render/ templates, markdown, highlighting, heatmap SVG
internal/server/ router, static files, git + registry proxy
web/ embedded templates and static assets
testdata/ sample Gitea JSON and golden output
docs/ spec and design decisions
Dockerfile golang build stage, alpine + git runtime, pinned by digest
deploy/ compose, production config, saturn patch and runbook
.gitea/workflows/ release: builds and pushes the image on a version tag
Docs
- docs/spec.md: what this is and isn't, the security rules and the build order.
- docs/decisions.md: choices made while building.
- docs/theme.md: how the look follows danieldaum.net.
- docs/security.md: each security rule mapped to code and tests.
Licences
Styles and palettes come from saturn
(danieldaum.net, MIT), which builds on Flexoki (MIT,
stephango.com/flexoki). Geist Mono and Geist
Pixel are under the SIL Open Font License. Icons are the ones Gitea
uses: file icons from
material-icon-theme
(MIT) and UI icons from Octicons (MIT,
GitHub). The licence files are in web/static/fonts/,
web/static/icons/material/ and web/static/icons/octicons/.
Security review
Step 10 of the spec. Each rule and each "done when" item maps to the code that
enforces it and the test that proves it. Run them all with just test.
Spec security rules
| # | Rule | Enforced in | Tested by |
|---|---|---|---|
| 1 | Generator uses no token, so it can only see public data (one exception: an optional token for the package listing) | gitea.Client sets credentials only on the package listing (tokenPath), refuses redirects, and the builder keeps only packages linked to repos that loaded anonymously. gitx runs git with no prompt, no credential helper, no user config and http(s) only. A repo the API marks private is refused anyway. |
fakeGitea fails any request that carries Authorization or Cookie; TestOutputIsSafe; TestTokenOnlyForPackages, TestTokenNotFollowedOnRedirect |
| 2 | One allowlist (config.json) |
Builder iterates cfg.Repos. Proxy checks HasRepo / HasImage. Packages are filtered to allowlisted repos and images. |
TestSiteGolden (missing and private repos absent), TestProxyRoutes (unlisted repo and image) |
| 3 | Router default is 404, with only the listed routes | server.route and proxyRoute. Dot segments, //, \ and NUL are refused before any file lookup. |
TestRoutes, TestProxyRoutes |
| 4 | Realm rewrite, strip Set-Cookie and Gitea headers, no client Authorization/Cookie on git |
newProxy Rewrite and ModifyResponse. Only forwardHeaders reach Gitea, so headers it might trust (X-WEBAUTH-USER) can't be injected. Non-Bearer challenges are dropped too, so git never prompts. |
TestProxyRoutes, TestProxyResponses, TestProxyDropsHeaders |
| 5 | Safe rendering | goldmark; raw HTML is never passed through, only rebuilt from an allowlist of tags and attributes (htmlRenderer), with links and images resolved like Markdown's and only http(s)/mailto hrefs; dangerous URLs blanked, html/template everywhere, highlighter escapes every token, 512 KB / binary limits, README images relative or https only |
TestSiteGolden (forbidden strings), TestOutputIsSafe (no <script, inline style= or on*= in any page), TestReadmeHTML (script, handlers, styles, javascript:, stray closes) |
| 6 | Security headers; raw never rendered as HTML | route sets the CSP, nosniff and no-referrer on every response. raw serves allowed images, text/plain or an attachment. Release assets are always attachments. |
TestRoutes (headers on every case, raw SVG and HTML are text/plain), TestProxyResponses |
| 7 | Container: non-root, read-only, no caps, no-new-privileges, only /data writable |
Dockerfile (USER 10001, HOME=/data), deploy/compose.yaml |
hadolint; container not yet run (see open items) |
| 8 | Trust X-Forwarded-* only from Pangolin |
clientIP uses trusted_proxies. The proxy strips X-Forwarded-* and Forwarded toward Gitea. |
TestClientIP, TestProxyRoutes |
| 9 | Cap git-upload-pack bodies, reject other bodies |
10 MB MaxBytesReader. A GET or HEAD with a body gets a 400. Proxy GET routes require no body. |
TestProxyResponses, TestBodyRejected |
"Done when"
| Item | Status |
|---|---|
git clone https://daum.dev/<repo>.git works and git push fails |
Proven with real git through the server: TestCloneAndPush. The fake Gitea there accepts pushes, so the refusal is ours. |
docker pull works anonymously and docker push fails |
Push methods and push scopes are refused (TestProxyRoutes). The pull path is unit-tested but not yet run against real Gitea. |
/api/v1/…, /user/login, /daniel/<repo> and unlisted repos are 404 |
TestRoutes, TestProxyRoutes |
| A private repo in config never appears anywhere | TestOutputIsSafe scans every output file, raw files included. A private, missing or renamed repo is skipped. Any other error fails the whole build, so a flaky API can't publish a site with repos missing. |
| Pages pass the CSP with no console errors and need no JS | No scripts anywhere. TestOutputIsSafe rules out inline styles and handlers; it caught goldmark's table-alignment style=, which is now an align attribute. Fonts, CSS and avatar are same-origin. Not yet checked in a real browser. |
Fixed during this review
- GFM table alignment rendered
style="text-align:…", which the CSP blocks. It is now analignattribute. - Registry routes: blob refs must be
sha256:<64 hex>, and manifest refs a valid tag or digest, so paths likeblobs/uploadsnever reach Gitea. WWW-Authenticatefrom Gitea is passed only when it is the registry's Bearer challenge (with the realm rewritten). Basic challenges are dropped, so git and docker never prompt for credentials that would go nowhere.- A repo is skipped only when Gitea says it's not found or private. Any other error fails the build and the previous one stays live.
Changes after the review
- The CSP now has
script-src 'self'for/static/copy.js(copy buttons). Inline scripts and handlers are still impossible, andTestOutputIsSafeallows exactly that one script tag and nothing else. - Repo SVGs on
raw/staytext/plaineven though/staticserves our own icons asimage/svg+xml(covered byTestRoutes). - The CSP now has
connect-src 'self'(2026-11-24), socopy.jscan fetch the raw file a file page's copy button copies. Requests go to this origin only;img-src https:was already a wider way out. See decisions, "Copy a file".
Second review (2026-11-23)
After issues, comments and the package token. Read through the server, proxy, rendering, git wrappers, builder, registry client, config, scripts, Dockerfile and compose file.
Fixed:
- Request headers to Gitea are an allowlist (
forwardHeaders). The proxy used to pass everything exceptCookieand someAuthorization. If Gitea ever had reverse-proxy login on (X-WEBAUTH-USER), a visitor could have claimed to be you.TestProxyDropsHeaders. - At most 8 concurrent git requests go through the proxy; more get a
503 with
Retry-After. Upload-pack is the expensive call for Gitea, and anyone can start one.TestProxyGitSlots. - Registry blobs are served as downloads (
application/octet-stream, attachment), like release assets, so no layer can render as a page on this origin. - Text from strangers is capped. Comments mean anyone with a Gitea
account can put text on the site. Issue, pull and comment bodies are cut
at 32 KB and a thread shows its newest 100 comments, saying how many it
left out.
TestUserTextLimits.
Checked and fine: path handling (dot segments, // and NUL refused; tree
entries with ./../empty segments skipped; only regular files served; no
open redirect through base_path), the HTML allowlist (javascript:
through entities, control characters or leading spaces fails URL parsing
and is dropped; the CSP blocks inline script anyway), git invocations
(--end-of-options, literal pathspecs, no prompts or helpers, http(s) only,
bare mirrors so no submodule or checkout hooks), registry layer reading
(64 MB compressed, 16 KB per file, streamed, 30 s timeout), the token (never
logged, never in config.json, never sent elsewhere), and the scripts
(theme.js only accepts [a-z]+ from the cookie).
Accepted risks
- Issue, pull, comment and release bodies can embed https images (the CSP
allows
img-src https:). With comments, that includes strangers' tracking pixels;no-referrerhides the page, not the visitor's IP. - Anyone with a Gitea account can write issues and comments that show up here (sanitized and capped). Gitea is tailnet-only with sign-ups off, so that's only accounts you create.
- README headings get automatic
ids, so a heading could share an id with a page element. The page's own elements come first, socopy.jsstill finds them; the worst case is a mis-scrolled anchor. - A repo with a file
xand a directoryx.htmlside by side makes its blob pages collide, and the build fails. It only affects your own repos and shows up as a build error, never as wrong content. - Builds load whole blobs (up to 50 MB) and patches into memory. That's fine for your own repos, but it isn't a defence against hostile repos.
Open items (need the real environment)
- Run the image on the host: read-only root, uid 10001, healthcheck.
docker pull daum.dev/daniel/<image>through Pangolin and Cloudflare.- Open pages in a browser and confirm there are no CSP console errors.
- Check Gitea's settings allow anonymous reads (
REQUIRE_SIGNIN_VIEW = false). govulncheckv1.10.0 on 2026-11-23 (Go 1.27.4, goldmark 1.8.7, chroma 2.27.0): no vulnerabilities found. Run it again before each release (go run golang.org/x/vuln/cmd/govulncheck@latest ./...; older releases crash on Go 1.27's standard library), and rebuild the image for new Go, Alpine and git releases (just digests).- Compose now sets
mem_limit/memswap_limit512m,cpus1.0 andpids_limit256. Watch the first builds for an OOM kill.