Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
58 lines (46 loc) · 2.34 KB
/
Copy pathMakefile
File metadata and controls
58 lines (46 loc) · 2.34 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
.PHONY: build frontend build-frontend build-go build-edge docker clean dev-frontend dev-go install-hooks setup
# Build everything: frontend + Go binary
build: frontend build-go
# Build the React frontend from standalone-ui package, copy to internal/web/spa/ for Go embed
STANDALONE_UI_DIR = $(shell cd ../.. && pwd)/packages/checker-standalone-ui
frontend:
cd $(STANDALONE_UI_DIR) && npm ci && VITE_GIT_SHA=$$(git rev-parse HEAD 2>/dev/null || echo "unknown") npm run build
rm -rf internal/web/spa
cp -r $(STANDALONE_UI_DIR)/dist internal/web/spa
git rev-parse HEAD > internal/web/spa/.version 2>/dev/null || echo "unknown" > internal/web/spa/.version
# Legacy: build from checker-core's own frontend/ directory
frontend-legacy:
cd frontend && npm ci && VITE_GIT_SHA=$$(git rev-parse HEAD 2>/dev/null || echo "unknown") npm run build
rm -rf internal/web/spa
cp -r frontend/dist internal/web/spa
git rev-parse HEAD > internal/web/spa/.version 2>/dev/null || echo "unknown" > internal/web/spa/.version
# Alias for backward compatibility
build-frontend: frontend
# Build the Go binary (expects internal/web/spa/ to exist)
build-go:
go build -ldflags="-s -w -X main.Version=$$(git rev-parse HEAD 2>/dev/null || echo unknown) -X main.BuildTime=$$(date -u +%Y-%m-%dT%H:%M:%SZ)" -o checker ./cmd/app
# Build the edge checker binary (no frontend needed)
GIT_TAG_OR_SHA = $(shell git describe --tags --exact-match 2>/dev/null || echo dev-$(shell git rev-parse --short HEAD 2>/dev/null || echo unknown))
build-edge:
go build -ldflags="-s -w -X main.Version=$(GIT_TAG_OR_SHA) -X github.com/imcitius/checker/pkg/edge.edgeClientVersion=$(GIT_TAG_OR_SHA)" -o bin/checker-edge ./cmd/edge
# Build Docker image
docker:
docker build -t checker .
# Clean build artifacts
clean:
rm -rf frontend/dist internal/web/spa checker app
# Run frontend dev server (proxies API to Go backend on :8080)
dev-frontend:
cd $(STANDALONE_UI_DIR) && npm run dev
# Run Go backend
dev-go:
go run ./cmd/app
# Install git hooks (pre-commit: auto-rebuild embedded SPA on frontend changes)
install-hooks:
@mkdir -p $$(git rev-parse --git-dir)/hooks
@cp dev/hooks/pre-commit $$(git rev-parse --git-dir)/hooks/pre-commit
@chmod +x $$(git rev-parse --git-dir)/hooks/pre-commit
@echo "Git hooks installed."
# First-time project setup: install dependencies and hooks
setup: install-hooks
cd frontend && npm install