-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
70 lines (59 loc) · 2.09 KB
/
Copy pathMakefile
File metadata and controls
70 lines (59 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
.PHONY: dev dev-backend dev-web clean build web-build go-build docker docker-compose-up docker-compose-down
# Basic targets:
# - make dev : run backend + frontend dev servers together
# - make clean : remove local data dir (reset all persisted config)
# - make build : build frontend + backend (host build)
# - make docker : build Docker image
# - make docker-compose-up : run via docker compose
# You can override these when needed:
# make clean HEARTH_DATA_DIR=/path/to/data
# make dev HEARTH_ADDR=:8787
HEARTH_ADDR ?= :8787
dev:
@set -e; \
ADDR="$${HEARTH_ADDR:-$(HEARTH_ADDR)}"; \
echo "Starting Hearth dev (backend + web)..."; \
echo "- Installing frontend deps if needed..."; \
(cd web && npm ci --prefer-offline --silent 2>/dev/null || npm ci); \
echo "- Backend: http://0.0.0.0$$ADDR"; \
echo "- Web dev: http://0.0.0.0:5173"; \
echo " (Access from phone using your local IP)"; \
(cd web && npm run dev -- --host 0.0.0.0) & WEB_PID=$$!; \
trap 'kill $$WEB_PID 2>/dev/null || true' INT TERM EXIT; \
HEARTH_ADDR="0.0.0.0$$ADDR" go run ./cmd/hearth
clean:
@set -e; \
DATA_DIR="$${HEARTH_DATA_DIR:-data}"; \
if [ -z "$$DATA_DIR" ] || [ "$$DATA_DIR" = "/" ]; then \
echo "Refusing to remove DATA_DIR='$$DATA_DIR'"; \
exit 1; \
fi; \
echo "Cleaning Hearth workspace..."; \
echo "- Removing data dir: $$DATA_DIR"; \
rm -rf "$$DATA_DIR"; \
echo "- Removing backend build outputs: dist/"; \
rm -rf dist; \
echo "- Removing frontend build/cache: web/dist web/.vite"; \
rm -rf web/dist web/.vite; \
echo "- Removing frontend deps: web/node_modules"; \
rm -rf web/node_modules; \
echo "Done."
build: web-build go-build
web-build:
@set -e; \
cd web; \
npm ci; \
npm run build
go-build:
@set -e; \
mkdir -p dist; \
CGO_ENABLED=0 go build -trimpath -ldflags "-s -w" -o dist/hearth ./cmd/hearth; \
echo "Built: dist/hearth"; \
CGO_ENABLED=0 go build -trimpath -ldflags "-s -w" -o dist/reset-password ./cmd/reset-password; \
echo "Built: dist/reset-password"
docker:
docker build -t hearth:local .
docker-compose-up:
docker compose up --build
docker-compose-down:
docker compose down