orchard
mirrorEvery 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
1//go:build embed
2
3package main
4
5import (
6 "embed"
7 "io/fs"
8 "log/slog"
9 "os"
10)
11
12// `all:` is required on build/dist: without it embed skips dot-prefixed entries,
13// and .vite/manifest.json is one, which the server treats as fatal.
14//
15//go:embed all:build/dist
16//go:embed build/static_maps
17var buildFS embed.FS
18
19func sub(dir string) fs.FS {
20 f, err := fs.Sub(buildFS, dir)
21 if err != nil {
22 slog.Error("startup failed", slog.Any("err", err))
23 os.Exit(1)
24 }
25 return f
26}
27
28func distFS() fs.FS { return sub("build/dist") }
29func mapsFS() fs.FS { return sub("build/static_maps") }