repos
/ status-rust master

status-rust

mirror archived upstream

Single-binary self-hosted uptime monitoring and status pages on Rust axum: HTTP probes, Lighthouse audits, SEO crawler, and PDF reports.

axumdockerrustself-hostedsqlitestatus-pageuptime-monitoringvite

1.9 KB · 56 lines · Makefile Raw History
 1CARGO ?= $(HOME)/.cargo/bin/cargo
 2PORT  ?= 8000
 3
 4.DEFAULT_GOAL := run
 5.PHONY: run build start clean push pull migrate
 6
 7# Dev: Vite watch + cargo run concurrently. Both die on Ctrl+C.
 8# Lighthouse runs in-process (subprocess to node_modules/.bin/lighthouse via
 9# `bun run --bun`), so the dev binary needs the root bun install too.
10run: frontend/node_modules dist/.vite/manifest.json node_modules
11	@trap 'kill 0' EXIT INT TERM; \
12	(cd frontend && bun run dev) & \
13	PORT=$(PORT) $(CARGO) run
14
15# Production build (Vite assets + release binary)
16build: frontend/node_modules
17	cd frontend && bun run build
18	$(CARGO) build --release
19
20# Run the release binary (after `make build`)
21start:
22	PORT=$(PORT) ./target/release/status
23
24# Nuke everything regenerable: build output, deps (frontend + lighthouse), and
25# the local data dir (sqlite + WAL/SHM — re-fetch with `make pull`).
26clean:
27	rm -rf target dist frontend/node_modules node_modules data
28
29push:
30	git remote | xargs -I R git push R master
31
32# Import an existing Django status SQLite into the rust schema.
33# `make migrate FROM=../status-django/db.sqlite3` (add FORCE=1 to wipe first).
34migrate:
35	@if [ -z "$(FROM)" ]; then echo "usage: make migrate FROM=<path-to-django.sqlite3> [FORCE=1]"; exit 2; fi
36	$(CARGO) run -- migrate "$(FROM)" $(if $(FORCE),--force,)
37
38# Pull production data (db, media) for local dev
39pull:
40	@SERVER=$$(git config --get remote.server.url | sed 's|ssh://||' | cut -d ':' -f 1 | cut -d '/' -f 1); \
41	NAME=$$(basename $$(pwd)); \
42	mkdir -p data; \
43	rsync -avz $$SERVER:/srv/data/$$NAME/db/db.sqlite3 data/db.sqlite3
44
45frontend/node_modules:
46	cd frontend && bun install
47
48# Lighthouse package, installed at the repo root because the lighthouse binary
49# lives at node_modules/.bin/lighthouse and reads node_modules/lighthouse at
50# runtime. Installed with bun (no nodejs/npm in the runtime image).
51node_modules: package.json
52	bun install --production
53
54dist/.vite/manifest.json: frontend/node_modules
55	cd frontend && bun run build