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.PHONY: run build frontend clean
2
3# Vite watches and rebuilds build/dist while Go serves it from disk. Templates
4# are embedded, so a template change needs a Go restart; CSS and JS changes only
5# need a browser reload.
6#
7# Go waits for the manifest rather than sleeping a guessed number of seconds:
8# the server treats a missing manifest as fatal, so the startup order matters.
9run:
10 cd frontend && bun run dev & \
11 i=0; while [ ! -f build/dist/.vite/manifest.json ]; do \
12 i=$$((i+1)); \
13 if [ $$i -gt 120 ]; then echo "vite did not produce a manifest in 60s" >&2; exit 1; fi; \
14 sleep 0.5; \
15 done; \
16 go run .
17
18frontend:
19 cd frontend && bun install --frozen-lockfile && bun run build
20
21# The release binary. -tags embed swaps assets_disk.go for assets_embed.go, so
22# the Vite bundle is compiled in and ../../bin/dash.bythewood.me is the whole
23# server.
24build: frontend
25 go build -tags embed -trimpath -ldflags="-s -w" -o ../../bin/dash.bythewood.me .
26
27clean:
28 rm -rf build frontend/node_modules