Makefile raw
1 # ORLY Nostr Relay Build System
2 .PHONY: all orly orly-db orly-acl orly-launcher proto clean test deploy web help
3 .PHONY: orly-db-badger orly-db-neo4j orly-acl-follows orly-acl-managed orly-acl-curation
4 .PHONY: all-split arm64-split
5 .PHONY: orly-sync-negentropy all-sync arm64-sync
6 .PHONY: orly-certs orly-nits all-sovereign
7 .PHONY: quick-deploy quick-deploy-restart deploy-both deploy-both-restart deploy-new list-releases rollback
8 .PHONY: upgrade upgrade-dry-run upgrade-no-restart upgrade-build
9 .PHONY: orly-unified arm64-unified
10 .PHONY: launcher-web orly-launcher-no-web
11 .PHONY: build build-web build-smesh
12
13 # Build flags
14 CGO_ENABLED ?= 0
15 GOOS ?= $(shell go env GOOS)
16 GOARCH ?= $(shell go env GOARCH)
17 BUILD_FLAGS = CGO_ENABLED=$(CGO_ENABLED) GOOS=$(GOOS) GOARCH=$(GOARCH)
18
19 # GOBIN for installed binaries (defaults to ~/go/bin)
20 GOBIN ?= $(shell go env GOBIN)
21 ifeq ($(GOBIN),)
22 GOBIN = $(shell go env GOPATH)/bin
23 endif
24
25 # === Frontend + Go Build ===
26
27 # Build everything: both frontends then unified Go binary
28 build: build-web build-smesh orly-unified
29 @echo "Build complete: web UI + smesh + unified binary"
30
31 # Build relay dashboard (Svelte/Rollup)
32 build-web:
33 cd app/web && bun install && bun run build
34
35 # Build smesh client (React/Vite)
36 build-smesh:
37 cd app/smesh && bun install && bun run build
38
39 # === Default Targets (Legacy) ===
40
41 # Default target: build everything (legacy monolithic)
42 all: orly orly-db orly-launcher
43 @echo "All binaries installed to $(GOBIN)"
44
45 # Build everything including ACL (when proto exists)
46 all-acl: proto orly orly-db orly-acl orly-launcher
47 @echo "All binaries (including ACL) installed to $(GOBIN)"
48
49 # === Split Binaries (New) ===
50
51 # Build split mode: orly + orly-db-badger + orly-acl-follows + launcher
52 all-split: proto orly orly-db-badger orly-acl-follows orly-launcher
53 @echo "Split mode binaries installed to $(GOBIN)"
54
55 # Build all split binaries (all backends and all ACL modes)
56 all-backends: proto orly orly-db-badger orly-db-neo4j orly-acl-follows orly-acl-managed orly-acl-curation orly-launcher
57 @echo "All backend and ACL mode binaries installed to $(GOBIN)"
58
59 # Main relay binary (uses go build to control output name since module is next.orly.dev)
60 orly:
61 $(BUILD_FLAGS) go build -o $(GOBIN)/orly .
62
63 # === Database Backends ===
64
65 # Legacy monolithic database server
66 orly-db:
67 $(BUILD_FLAGS) go install ./cmd/orly-db
68
69 # Badger database server
70 orly-db-badger:
71 $(BUILD_FLAGS) go install ./cmd/orly-db-badger
72
73 # Neo4j database server
74 orly-db-neo4j:
75 $(BUILD_FLAGS) go install ./cmd/orly-db-neo4j
76
77 # === ACL Modes ===
78
79 # Legacy monolithic ACL server (requires proto generation first)
80 orly-acl:
81 $(BUILD_FLAGS) go install ./cmd/orly-acl
82
83 # Follows ACL server (whitelist based on admin follows)
84 orly-acl-follows:
85 $(BUILD_FLAGS) go install ./cmd/orly-acl-follows
86
87 # Managed ACL server (NIP-86 fine-grained control)
88 orly-acl-managed:
89 $(BUILD_FLAGS) go install ./cmd/orly-acl-managed
90
91 # Curation ACL server (rate-limited trust tiers)
92 orly-acl-curation:
93 $(BUILD_FLAGS) go install ./cmd/orly-acl-curation
94
95 # Process supervisor/launcher
96 orly-launcher: launcher-web
97 $(BUILD_FLAGS) go install ./cmd/orly-launcher
98
99 # Build launcher admin web UI
100 launcher-web:
101 cd cmd/orly-launcher/web && bun install && bun run build
102
103 # Build launcher without web UI (for development)
104 orly-launcher-no-web:
105 $(BUILD_FLAGS) go install ./cmd/orly-launcher
106
107 # === Unified Binary (New Architecture) ===
108
109 # Unified binary with Badger driver (minimal, for most deployments)
110 orly-unified:
111 $(BUILD_FLAGS) go install ./cmd/orly
112
113 # Build unified binary for ARM64
114 arm64-unified:
115 $(MAKE) GOOS=linux GOARCH=arm64 orly-unified
116
117 # Generate protobuf code
118 proto:
119 cd proto && buf generate
120
121 # === Cross-Compile for ARM64 ===
122
123 # Build for ARM64 (relay.orly.dev deployment) - legacy
124 arm64:
125 $(MAKE) GOOS=linux GOARCH=arm64 all
126
127 # Build everything for ARM64 including ACL - legacy
128 arm64-acl:
129 $(MAKE) GOOS=linux GOARCH=arm64 all-acl
130
131 # Build split mode for ARM64 (recommended for relay.orly.dev)
132 arm64-split:
133 $(MAKE) GOOS=linux GOARCH=arm64 all-split
134
135 # Build all backends for ARM64
136 arm64-backends:
137 $(MAKE) GOOS=linux GOARCH=arm64 all-backends
138
139 # === Other Targets ===
140
141 # Build web UI and embed (alias for build)
142 web: build-web build-smesh
143
144 # Clean build artifacts (note: binaries are in GOBIN)
145 clean:
146 go clean -i ./...
147 @echo "Cleaned. Note: installed binaries are in $(GOBIN)"
148
149 # Run tests
150 test:
151 ./scripts/test.sh
152
153 # Deploy to relay.orly.dev (builds on remote) - legacy
154 deploy:
155 ssh relay.orly.dev 'cd ~/src/next.orly.dev && git pull origin main && make all && sudo /usr/sbin/setcap cap_net_bind_service=+ep ~/go/bin/next.orly.dev && sudo systemctl restart orly'
156
157 # Deploy with ACL server - legacy
158 deploy-acl:
159 ssh relay.orly.dev 'cd ~/src/next.orly.dev && git pull origin main && make all-acl && sudo /usr/sbin/setcap cap_net_bind_service=+ep ~/go/bin/next.orly.dev && sudo systemctl restart orly'
160
161 # Deploy split mode (recommended)
162 deploy-split:
163 ssh relay.orly.dev 'cd ~/src/next.orly.dev && git pull origin main && make all-split && sudo /usr/sbin/setcap cap_net_bind_service=+ep ~/go/bin/next.orly.dev && sudo systemctl restart orly'
164
165 # === Symlink-Based Deployment ===
166
167 # Certificate service
168 orly-certs:
169 $(BUILD_FLAGS) go install ./cmd/orly-certs
170
171 # Bitcoin node gRPC shim
172 orly-nits:
173 $(BUILD_FLAGS) go install ./cmd/orly-nits
174
175 # Sovereign stack: all services under orly-launcher (nits/luk/strela built externally)
176 all-sovereign: proto orly orly-db-badger orly-acl-follows orly-nits orly-sync-negentropy orly-certs orly-launcher
177 @echo "Sovereign stack binaries installed to $(GOBIN)"
178
179 orly-sync-negentropy:
180 $(BUILD_FLAGS) go install ./cmd/orly-sync-negentropy
181
182 # Build all sync services
183 all-sync: proto orly orly-db orly-acl orly-launcher orly-sync-negentropy
184 @echo "All sync service binaries installed to $(GOBIN)"
185
186 # ARM64 for sync services
187 arm64-sync:
188 $(MAKE) GOOS=linux GOARCH=arm64 all-sync
189
190 # Quick deploy: build amd64 unified binary and deploy to relay.orly.dev
191 quick-deploy:
192 ./scripts/build-and-deploy.sh relay.orly.dev
193
194 # Quick deploy with restart
195 quick-deploy-restart:
196 ./scripts/build-and-deploy.sh relay.orly.dev --restart
197
198 # Deploy to both relays
199 deploy-both:
200 ./scripts/build-and-deploy.sh both
201
202 # Deploy to both relays with restart
203 deploy-both-restart:
204 ./scripts/build-and-deploy.sh both --restart
205
206 # Deploy to new.orly.dev only
207 deploy-new:
208 ./scripts/build-and-deploy.sh new.orly.dev
209
210 # List available releases on relay
211 list-releases:
212 ./scripts/deploy-orly.sh --host relay.orly.dev --list
213
214 # Rollback to previous release
215 rollback:
216 ./scripts/deploy-orly.sh --host relay.orly.dev --rollback --restart
217
218 # === Upgrade (Version-Driven Deploy) ===
219
220 # Full upgrade: build unified binary + web UI, deploy to relay.orly.dev, restart
221 upgrade:
222 ./scripts/upgrade.sh
223
224 # Dry run: show what would happen without executing
225 upgrade-dry-run:
226 ./scripts/upgrade.sh --dry-run
227
228 # Deploy without restarting (for staged rollouts)
229 upgrade-no-restart:
230 ./scripts/upgrade.sh --no-restart
231
232 # Build only (no deploy, no restart)
233 upgrade-build:
234 ./scripts/upgrade.sh --build-only
235
236 # Help
237 help:
238 @echo "ORLY Build Targets:"
239 @echo ""
240 @echo " Binaries are installed to GOBIN ($(GOBIN))"
241 @echo ""
242 @echo " Split Mode (Recommended):"
243 @echo " all-split - Build orly + orly-db-badger + orly-acl-follows + launcher"
244 @echo " all-backends - Build all database backends and ACL modes"
245 @echo " arm64-split - Cross-compile split mode for ARM64"
246 @echo " deploy-split - Deploy split mode to relay.orly.dev"
247 @echo ""
248 @echo " Database Backends:"
249 @echo " orly-db-badger - Build Badger database server"
250 @echo " orly-db-neo4j - Build Neo4j database server"
251 @echo ""
252 @echo " ACL Modes:"
253 @echo " orly-acl-follows - Build Follows ACL server (whitelist)"
254 @echo " orly-acl-managed - Build Managed ACL server (NIP-86)"
255 @echo " orly-acl-curation - Build Curation ACL server (rate limits)"
256 @echo ""
257 @echo " Legacy (Monolithic):"
258 @echo " all - Build orly + orly-db + launcher"
259 @echo " all-acl - Build all including orly-acl"
260 @echo " orly-db - Build monolithic database server"
261 @echo " orly-acl - Build monolithic ACL server"
262 @echo ""
263 @echo " Build (Frontend + Go):"
264 @echo " build - Build web + smesh frontends then unified Go binary"
265 @echo " build-web - Build relay dashboard (Svelte/Rollup) to app/web/dist"
266 @echo " build-smesh - Build smesh client (React/Vite) to app/smesh/dist"
267 @echo ""
268 @echo " Core:"
269 @echo " orly - Build main relay binary"
270 @echo " orly-launcher - Build process supervisor with admin UI"
271 @echo " orly-launcher-no-web - Build launcher without admin UI"
272 @echo " proto - Generate protobuf code"
273 @echo " web - Rebuild both embedded web UIs (alias for build-web + build-smesh)"
274 @echo " launcher-web - Rebuild launcher admin web UI"
275 @echo " test - Run test suite"
276 @echo " clean - Clean build artifacts"
277 @echo " help - Show this help"
278 @echo ""
279 @echo " Sovereign Stack:"
280 @echo " orly-nits - Build Bitcoin node gRPC shim"
281 @echo " all-sovereign - Build all orly-managed services (nits/relay/db/acl/sync/certs)"
282 @echo ""
283 @echo " Sync Services:"
284 @echo " orly-sync-negentropy - Build NIP-77 negentropy sync server"
285 @echo " all-sync - Build all including sync services"
286 @echo " arm64-sync - Cross-compile sync services for ARM64"
287 @echo ""
288 @echo " Unified Binary (New Architecture):"
289 @echo " orly-unified - Build unified binary with subcommands"
290 @echo " arm64-unified - Cross-compile unified binary for ARM64"
291 @echo ""
292 @echo " Unified Binary Usage:"
293 @echo " orly-unified db --driver=badger - Run Badger database server"
294 @echo " orly-unified db health - Run database health check"
295 @echo " orly-unified db repair --dry-run - Preview database repairs"
296 @echo " orly-unified acl --driver=follows - Run follows ACL server"
297 @echo ""
298 @echo " Upgrade (Recommended — version-driven deploy):"
299 @echo " upgrade - Build unified amd64 binary + web UI, deploy, restart"
300 @echo " upgrade-dry-run - Show what would happen without executing"
301 @echo " upgrade-no-restart - Deploy without restarting the service"
302 @echo " upgrade-build - Build locally without deploying"
303 @echo ""
304 @echo " Quick Deployment (legacy symlink-based):"
305 @echo " quick-deploy - Build ARM64 and deploy to relay.orly.dev"
306 @echo " quick-deploy-restart - Build, deploy, and restart service"
307 @echo " deploy-both - Deploy to both relay.orly.dev and new.orly.dev"
308 @echo " deploy-both-restart - Deploy and restart both relays"
309 @echo " deploy-new - Deploy to new.orly.dev only"
310 @echo " list-releases - List available releases on relay"
311 @echo " rollback - Rollback to previous release"
312