repos
/ orchard main

orchard

mirror

Every site I host, in one repo, along with the Cloudflare Tunnel and Caddy that front them. It's all Go, Vite, and SQLite, and it runs on a desktop at home with nothing listening on an inbound port.

blogbuncaddycloudflare-tunneldockergogolanghomelabhtml-templatemonorepoself-hostedseosqlitestatic-sitetypstuptime-monitoringviteweb-analytics

708 B · 33 lines · Go Raw History
 1//go:build embed
 2
 3package main
 4
 5import (
 6	"embed"
 7	"io/fs"
 8	"log/slog"
 9	"os"
10)
11
12// A release build is one file with no SITE_* variables to set. `make build` runs
13// Vite and typst first, since the directives below read those directories at
14// compile time; `all:` is needed or embed skips .vite/manifest.json.
15//
16//go:embed all:build/dist
17//go:embed build/pdfs
18//go:embed build/og
19var buildFS embed.FS
20
21func sub(dir string) fs.FS {
22	f, err := fs.Sub(buildFS, dir)
23	if err != nil {
24		slog.Error("startup failed", slog.Any("err", err))
25		os.Exit(1)
26	}
27	return f
28}
29
30func distFS() fs.FS { return sub("build/dist") }
31func pdfsFS() fs.FS { return sub("build/pdfs") }
32func ogFS() fs.FS   { return sub("build/og") }