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

1.8 KB · 49 lines · Makefile Raw History
 1.PHONY: run build frontend lighthouse preview clean
 2
 3# Vite watches and rebuilds build/dist while Go serves it from disk. Templates are
 4# 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,
 9# and this site's first Vite build is slow: Bootstrap SCSS plus Chart.js and
10# the Monaspace font.
11run:
12	cd frontend && bun run dev & \
13	i=0; while [ ! -f build/dist/.vite/manifest.json ]; do \
14		i=$$((i+1)); \
15		if [ $$i -gt 120 ]; then echo "vite did not produce a manifest in 60s" >&2; exit 1; fi; \
16		sleep 0.5; \
17	done; \
18	go run .
19
20frontend:
21	cd frontend && bun install --frozen-lockfile && bun run build
22
23# The lighthouse CLI, installed at the site root rather than in frontend/,
24# because it is a program the Go binary execs rather than a frontend dependency.
25# lighthouse.go looks for it at ./node_modules/.bin/lighthouse.
26#
27# Its own target rather than part of `build`: it is a large install that changes
28# rarely, and a local checkout that skips it still runs, recording "lighthouse
29# CLI not installed" against each property.
30lighthouse:
31	bun install --frozen-lockfile
32
33# The release binary. -tags embed swaps assets_disk.go for assets_embed.go, so
34# the Vite bundle is compiled into the executable. `frontend` is a requirement
35# rather than ordering: the embed directive reads build/dist at compile time and
36# fails if it is not there.
37build: frontend
38	go build -tags embed -trimpath -ldflags="-s -w" -o ../../bin/status.bythewood.me .
39
40# Render an ntfy notification to stdout without waiting for something to
41# break.
42preview:
43	go run . -preview-alert down
44	@echo
45	go run . -preview-alert recovery
46
47clean:
48	rm -rf build frontend/node_modules node_modules data