-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
147 lines (115 loc) · 4.21 KB
/
Copy pathMakefile
File metadata and controls
147 lines (115 loc) · 4.21 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
.PHONY: help dev-infra dev-infra-down dev-api dev-web web embed app run clean gen-web-types check-web-types \
api-ent api-interfaces api-migrate api-migrate-checksum api-test api-fmt api-run \
web-build web-dev web-lint web-typecheck web-gen \
operator-generate operator-manifests operator-build operator-run operator-test \
installer-build installer-run
WEB_DIR := apps/web
API_DIR := apps/api
OPERATOR_DIR := apps/operator
INSTALLER_DIR := apps/installer
EMBED_DIR := $(API_DIR)/internal/web/dist
COMPOSE := deploy/compose/docker-compose.yaml
help:
@echo "Local development (no Docker for the app itself):"
@echo " make dev-infra - Start Postgres + Redis (docker compose)"
@echo " make dev-infra-down - Stop Postgres + Redis"
@echo " make dev-api - Run the API with hot reload-free Go (serves the stub SPA + API on :8089)"
@echo " make dev-web - Run the Vite dev server (:5173), proxying /api/go to the API"
@echo ""
@echo "Production-like single binary (SPA embedded in the API):"
@echo " make web - Build the SPA to $(WEB_DIR)/dist"
@echo " make embed - Copy the SPA build into $(EMBED_DIR)"
@echo " make app - web + embed + build $(API_DIR)/bin/unbind"
@echo " make run - Build the single binary and run it on :8089"
@echo ""
@echo "Web client types (generated from the API's OpenAPI spec, no server needed):"
@echo " make gen-web-types - Regenerate apps/web client types from the local API code"
@echo " make check-web-types - Fail if the committed web types are out of sync with the API"
@echo ""
@echo "API (apps/api):"
@echo " make api-ent - Generate ent entities"
@echo " make api-interfaces - Generate interfaces and mocks"
@echo " make api-migrate NAME=x - Create a migration"
@echo " make api-migrate-checksum - Regenerate migration checksum"
@echo " make api-test - Run API tests"
@echo " make api-fmt - Format API code"
@echo " make api-run - Run the API"
@echo ""
@echo "Web (apps/web):"
@echo " make web-build / web-dev / web-lint / web-typecheck / web-gen"
@echo ""
@echo "Operator (apps/operator):"
@echo " make operator-generate / operator-manifests / operator-build / operator-run / operator-test"
@echo ""
@echo "Installer (apps/installer):"
@echo " make installer-build / installer-run"
# --- Local infra ---
dev-infra:
docker compose -f $(COMPOSE) up -d
dev-infra-down:
docker compose -f $(COMPOSE) down
# --- Two-process dev loop (hot reload for the UI) ---
dev-api:
cd $(API_DIR) && go run ./cmd/api
dev-web:
cd $(WEB_DIR) && VITE_DEV_API_PROXY=http://localhost:8089 npm run dev
# --- Single-binary build (the API serves the real SPA) ---
web:
cd $(WEB_DIR) && npm run build
embed: web
rm -rf $(EMBED_DIR)
cp -r $(WEB_DIR)/dist $(EMBED_DIR)
app: embed
cd $(API_DIR) && CGO_ENABLED=0 go build -trimpath -ldflags "-s -w" -o bin/unbind ./cmd/api
run: app
cd $(API_DIR) && ./bin/unbind
clean:
rm -rf $(WEB_DIR)/dist $(API_DIR)/bin
git checkout -- $(EMBED_DIR)/index.html 2>/dev/null || true
# --- Web client type generation ---
gen-web-types:
./scripts/gen-web-types.sh
check-web-types:
./scripts/check-web-types.sh
# --- API (apps/api) ---
api-ent:
$(MAKE) -C $(API_DIR) ent
api-interfaces:
$(MAKE) -C $(API_DIR) interfaces
api-migrate:
$(MAKE) -C $(API_DIR) migrate NAME=$(NAME)
api-migrate-checksum:
$(MAKE) -C $(API_DIR) migrate:checksum
api-test:
$(MAKE) -C $(API_DIR) tests
api-fmt:
$(MAKE) -C $(API_DIR) fmt
api-run:
cd $(API_DIR) && go run ./cmd/api
# --- Web (apps/web) ---
web-build:
cd $(WEB_DIR) && npm run build
web-dev:
cd $(WEB_DIR) && npm run dev
web-lint:
cd $(WEB_DIR) && npm run lint
web-typecheck:
cd $(WEB_DIR) && npm run typecheck
web-gen:
cd $(WEB_DIR) && npm run generate-sdk
# --- Operator (apps/operator) ---
operator-generate:
$(MAKE) -C $(OPERATOR_DIR) generate
operator-manifests:
$(MAKE) -C $(OPERATOR_DIR) manifests
operator-build:
$(MAKE) -C $(OPERATOR_DIR) build
operator-run:
$(MAKE) -C $(OPERATOR_DIR) run
operator-test:
$(MAKE) -C $(OPERATOR_DIR) test
# --- Installer (apps/installer) ---
installer-build:
cd $(INSTALLER_DIR) && go build -o bin/installer ./cmd
installer-run:
cd $(INSTALLER_DIR) && go run ./cmd