-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathMakefile
More file actions
684 lines (593 loc) Β· 26.4 KB
/
Makefile
File metadata and controls
684 lines (593 loc) Β· 26.4 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
# Airborne Project Makefile
# Consolidated build system for the entire Airborne project
# Manages server, analytics, infrastructure, and development workflows
SHELL := /usr/bin/env bash
SUPERPOSITION_URL ?= http://localhost:8080
KEYCLOAK_HOST_URL ?= http://localhost:8180/realms/master
LOCALSTACK_HOST_URL ?= http://localhost:4566/_localstack/health
GRAFANA_HOST_URL ?= http://localhost:4000
VICTORIA_METRICS_HOST_URL ?= http://localhost:8428
POSTGRES_HOST ?= localhost
POSTGRES_PORT ?= 5433
FMT_FLAGS := --all
LINT_FLAGS := --all-targets
CARGO_FLAGS := --color always --no-default-features
ENV_FILE_VM ?= airborne_analytics_server/.env.victoria-metrics
ENV_FILE_KC ?= airborne_analytics_server/.env.kafka-clickhouse
SMITHY_BUILD_SRC := smithy/output/source
# ANSI color codes
export GREEN := $(shell printf '\033[0;32m')
export YELLOW := $(shell printf '\033[1;33m')
export RED := $(shell printf '\033[0;31m')
export NC := $(shell printf '\033[0m') # No Color
export SMITHY_MAVEN_REPOS = https://repo1.maven.org/maven2%7Chttps://sandbox.assets.juspay.in/smithy/m2
# Docker detection
HAS_DOCKER := $(shell command -v docker > /dev/null; echo $$?)
HAS_PODMAN := $(shell command -v podman > /dev/null; echo $$?)
ifeq ($(HAS_DOCKER),0)
DOCKER := docker
else ifeq ($(HAS_PODMAN),0)
DOCKER := podman
export PODMAN_COMPOSE_WARNING_LOGS = false
else
$(error "Neither docker nor podman found, please install one of them.")
endif
COMPOSE := $(DOCKER) compose
define read-container-name
yq -r '.services["$(2)"].container_name' $(1)/docker-compose.yml
endef
define check-container
$(DOCKER) ps | grep $(1) 2>&1 > /dev/null; echo $$?
endef
DB_CONTAINER_NAME = $(shell $(call read-container-name,airborne_server,postgres))
DB_UP = $(shell $(call check-container,$(DB_CONTAINER_NAME)))
LSTACK_CONTAINER_NAME = $(shell $(call read-container-name,airborne_server,localstack))
LSTACK_UP = $(shell $(call check-container,$(LSTACK_CONTAINER_NAME)))
SUPERPOSITION_CONTAINER_NAME = $(shell $(call read-container-name,airborne_server,superposition))
SUPERPOSITION_UP = $(shell $(call check-container,$(SUPERPOSITION_CONTAINER_NAME)))
KEYCLOAK_DB_CONTAINER_NAME = $(shell $(call read-container-name,airborne_server,keycloak-db))
KEYCLOAK_DB_UP = $(shell $(call check-container,$(KEYCLOAK_DB_CONTAINER_NAME)))
KEYCLOAK_CONTAINER_NAME = $(shell $(call read-container-name,airborne_server,keycloak))
KEYCLOAK_UP = $(shell $(call check-container,$(KEYCLOAK_CONTAINER_NAME)))
GRAFANA_CONTAINER_NAME = $(shell $(call read-container-name,airborne_analytics_server,grafana))
GRAFANA_UP = $(shell $(call check-container,$(GRAFANA_CONTAINER_NAME)))
VICTORIA_METRICS_CONTAINER_NAME = $(shell $(call read-container-name,airborne_analytics_server,victoria-metrics))
VICTORIA_METRICS_UP = $(shell $(call check-container,$(VICTORIA_METRICS_CONTAINER_NAME)))
ZOOKEEPER_CONTAINER_NAME = $(shell $(call read-container-name,airborne_analytics_server,zookeeper))
ZOOKEEPER_UP = $(shell $(call check-container,$(ZOOKEEPER_CONTAINER_NAME)))
KAFKA_CONTAINER_NAME = $(shell $(call read-container-name,airborne_analytics_server,kafka))
KAFKA_UP = $(shell $(call check-container,$(KAFKA_CONTAINER_NAME)))
CLICKHOUSE_CONTAINER_NAME = $(shell $(call read-container-name,airborne_analytics_server,clickhouse-server))
CLICKHOUSE_UP = $(shell $(call check-container,$(CLICKHOUSE_CONTAINER_NAME)))
KAFKA_UI_CONTAINER_NAME = $(shell $(call read-container-name,airborne_analytics_server,kafka-ui))
KAFKA_UI_UP = $(shell $(call check-container,$(KAFKA_UI_CONTAINER_NAME)))
.PHONY: help env-file analytics-env-file db localstack superposition keycloak-db keycloak grafana victoria-metrics zookeeper kafka clickhouse kafka-ui setup airborne-server superposition-init keycloak-init localstack-init db-migration kill run stop cleanup test status lint-fix check fmt lint commit amend amend-no-edit node-dependencies dashboard docs analytics-server run-kafka-clickhouse run-victoria-metrics run-analytics frontend-check frontend-lint frontend-lint-fix frontend-format
default: help
help:
@echo "$(GREEN)Airborne Project Management$(NC)"
@echo ""
@echo "$(YELLOW)Main Commands:$(NC)"
@printf " $(GREEN)%-20s$(NC) %s\n" "run" "Run the complete Airborne server development environment"
@printf " $(GREEN)%-20s$(NC) %s\n" "run-analytics" "Run the analytics server development environment"
@printf " $(GREEN)%-20s$(NC) %s\n" "stop" "Stop all services gracefully"
@printf " $(GREEN)%-20s$(NC) %s\n" "status" "Show current system status"
@printf " $(GREEN)%-20s$(NC) %s\n" "test" "Run test suite"
@printf " $(GREEN)%-20s$(NC) %s\n" "cleanup" "Clean up containers and volumes"
@echo ""
@echo "$(YELLOW)Setup Commands:$(NC)"
@printf " $(GREEN)%-20s$(NC) %s\n" "setup" "Set up all dependencies with encryption (default)"
@printf " $(GREEN)%-20s$(NC) %s\n" "" " make setup USE_ENCRYPTED_SECRETS=false"
@printf " $(GREEN)%-20s$(NC) %s\n" "" " make setup USE_ENCRYPTED_SECRETS=true (default)"
@printf " $(GREEN)%-20s$(NC) %s\n" "env-file" "Create .env file from .env.example"
@printf " $(GREEN)%-20s$(NC) %s\n" "airborne-server" "Build the Airborne server"
@printf " $(GREEN)%-20s$(NC) %s\n" "analytics-server" "Build the analytics server"
@echo ""
@echo "$(YELLOW)Infrastructure Services:$(NC)"
@printf " $(GREEN)%-20s$(NC) %s\n" "db" "Start PostgreSQL database"
@printf " $(GREEN)%-20s$(NC) %s\n" "localstack" "Start LocalStack (AWS mock)"
@printf " $(GREEN)%-20s$(NC) %s\n" "superposition" "Start Superposition service"
@printf " $(GREEN)%-20s$(NC) %s\n" "keycloak" "Start Keycloak authentication"
@printf " $(GREEN)%-20s$(NC) %s\n" "keycloak-db" "Start Keycloak database"
@echo ""
@echo "$(YELLOW)Analytics Services:$(NC)"
@printf " $(GREEN)%-20s$(NC) %s\n" "grafana" "Start Grafana dashboard"
@printf " $(GREEN)%-20s$(NC) %s\n" "victoria-metrics" "Start Victoria Metrics time series DB"
@printf " $(GREEN)%-20s$(NC) %s\n" "zookeeper" "Start Zookeeper coordination service"
@printf " $(GREEN)%-20s$(NC) %s\n" "kafka" "Start Kafka message broker"
@printf " $(GREEN)%-20s$(NC) %s\n" "clickhouse" "Start ClickHouse analytics database"
@printf " $(GREEN)%-20s$(NC) %s\n" "kafka-ui" "Start Kafka UI management interface"
@echo ""
@echo "$(YELLOW)Frontend Build Commands:$(NC)"
@printf " $(GREEN)%-20s$(NC) %s\n" "node-dependencies" "Install Node.js dependencies for React apps"
@printf " $(GREEN)%-20s$(NC) %s\n" "dashboard" "Build the dashboard React app"
@printf " $(GREEN)%-20s$(NC) %s\n" "docs" "Build the docs React app"
@printf " $(GREEN)%-20s$(NC) %s\n" "home" "Build the home React app"
@echo ""
@echo "$(YELLOW)Analytics Development:$(NC)"
@printf " $(GREEN)%-20s$(NC) %s\n" "run-kafka-clickhouse" "Run analytics with Kafka + ClickHouse stack"
@printf " $(GREEN)%-20s$(NC) %s\n" "run-victoria-metrics" "Run analytics with Grafana + Victoria Metrics stack"
@echo ""
@echo "$(YELLOW)Database Commands:$(NC)"
@printf " $(GREEN)%-20s$(NC) %s\n" "db-migration" "Run database migrations using Diesel"
@echo ""
@echo "$(YELLOW)Initialization Commands:$(NC)"
@printf " $(GREEN)%-20s$(NC) %s\n" "superposition-init" "Initialize Superposition organization"
@printf " $(GREEN)%-20s$(NC) %s\n" "keycloak-init" "Initialize Keycloak realm and client"
@printf " $(GREEN)%-20s$(NC) %s\n" "localstack-init" "Initialize LocalStack S3 buckets"
@echo ""
@echo "$(YELLOW)Utility Commands:$(NC)"
@printf " $(GREEN)%-20s$(NC) %s\n" "kill" "Kill running airborne-server processes"
@echo ""
@echo "$(YELLOW)Code Quality Commands:$(NC)"
@printf " $(GREEN)%-20s$(NC) %s\n" "check" "Run format check and linting (CI mode) for all projects"
@printf " $(GREEN)%-20s$(NC) %s\n" "fmt" "Format Rust code using rustfmt"
@printf " $(GREEN)%-20s$(NC) %s\n" "lint" "Run Clippy linter on Rust code"
@printf " $(GREEN)%-20s$(NC) %s\n" "lint-fix" "Run Clippy with automatic fixes"
@printf " $(GREEN)%-20s$(NC) %s\n" "frontend-check" "Run frontend type-check, lint, and format checks"
@printf " $(GREEN)%-20s$(NC) %s\n" "frontend-lint" "Run ESLint on frontend projects"
@printf " $(GREEN)%-20s$(NC) %s\n" "frontend-lint-fix" "Run ESLint with automatic fixes on frontend"
@printf " $(GREEN)%-20s$(NC) %s\n" "frontend-format" "Format frontend code using Prettier"
@echo ""
@echo "$(YELLOW)Git Integration Commands:$(NC)"
@printf " $(GREEN)%-20s$(NC) %s\n" "commit" "Run quality checks and commit changes"
@printf " $(GREEN)%-20s$(NC) %s\n" "amend" "Amend the last commit with quality checks"
@printf " $(GREEN)%-20s$(NC) %s\n" "amend-no-edit" "Amend the last commit without editing message"
@echo ""
@echo "$(YELLOW)Usage Examples:$(NC)"
@echo " make run # Start Airborne server for development"
@echo " make run-analytics # Start analytics server for development"
@echo " make setup # Set up dependencies only"
@echo " make status # Check what's running"
@echo " make cleanup # Clean up and start fresh"
@echo " make db-migration # Run database migrations"
env-file:
@echo "$(YELLOW)π§ Checking environment file...$(NC)"
@if ! [ -e airborne_server/.env ]; then \
echo "$(YELLOW).env missing, copying .env.example as .env$(NC)" && \
cp airborne_server/.env.example airborne_server/.env; \
cat airborne_server/.env.docker.extra >> airborne_server/.env; \
fi
@echo "$(GREEN)β
Environment file ready$(NC)"
setup-encrypted:
@echo "$(YELLOW)π Setting up encrypted environment...$(NC)"
@chmod +x airborne_server/scripts/encrypt-envs.sh
@cd airborne_server && ./scripts/encrypt-envs.sh
@echo "$(GREEN)β
Encrypted environment setup complete$(NC)"
setup-plaintext:
@echo "$(YELLOW)π Setting up plaintext environment...$(NC)"
@chmod +x airborne_server/scripts/encrypt-envs.sh
@cd airborne_server && ./scripts/encrypt-envs.sh --plaintext
@echo "$(GREEN)β
Plaintext environment setup complete$(NC)"
analytics-env-file:
@echo "$(YELLOW)π§ Checking analytics environment file...$(NC)"
@if ! [ -e airborne_analytics_server/.env ]; then \
echo "$(YELLOW).env missing, copying .env.example as .env$(NC)" && \
cp airborne_analytics_server/.env.example airborne_analytics_server/.env; \
fi
@echo "$(GREEN)β
Analytics environment file ready$(NC)"
db:
ifndef CI
ifeq ($(DB_UP),1)
@echo "$(YELLOW)π Starting PostgreSQL container...$(NC)"
$(COMPOSE) -f airborne_server/docker-compose.yml up -d postgres
endif
else
@echo "$(YELLOW)Skipping postgres container-setup in CI.$(NC)"
endif
@echo "$(YELLOW)π Checking PostgreSQL connection...$(NC)"
@while ! pg_isready -h $(POSTGRES_HOST) -p $(POSTGRES_PORT) >/dev/null 2>&1; do \
printf "."; sleep 1; \
done
@echo "$(GREEN) β
PostgreSQL ready$(NC)"
localstack:
ifndef CI
ifeq ($(LSTACK_UP),1)
@echo "$(YELLOW)βοΈ Starting LocalStack container...$(NC)"
$(COMPOSE) -f airborne_server/docker-compose.yml up -d localstack
endif
else
@echo "$(YELLOW)Skipping localstack container-setup in CI.$(NC)"
endif
@echo "$(YELLOW)βοΈ Checking LocalStack connection...$(NC)"
@RETRY=0; \
while [ $$RETRY -lt 30 ]; do \
if curl -s -f $(LOCALSTACK_HOST_URL) >/dev/null 2>&1; then \
break; \
fi; \
printf "."; sleep 1; RETRY=$$((RETRY + 1)); \
done
@echo "$(GREEN) β
LocalStack ready$(NC)"
superposition:
ifndef CI
ifeq ($(SUPERPOSITION_UP),1)
@echo "$(YELLOW)π Starting Superposition container...$(NC)"
$(COMPOSE) -f airborne_server/docker-compose.yml up -d superposition
endif
else
@echo "$(YELLOW)Skipping superposition container-setup in CI.$(NC)"
endif
@echo "$(YELLOW)π Checking Superposition health...$(NC)"
@RETRY=0; \
while [ $$RETRY -lt 60 ]; do \
if curl -s -o /dev/null -w "%{http_code}" "$(SUPERPOSITION_URL)/health" | grep -E "200" >/dev/null; then \
break; \
fi; \
printf "."; sleep 2; RETRY=$$((RETRY + 1)); \
done
@echo "$(GREEN) β
Superposition ready$(NC)"
keycloak-db:
ifndef CI
ifeq ($(KEYCLOAK_DB_UP),1)
@echo "$(YELLOW)π Starting Keycloak DB container...$(NC)"
$(COMPOSE) -f airborne_server/docker-compose.yml up -d keycloak-db
endif
else
@echo "$(YELLOW)Skipping keycloak-db container-setup in CI.$(NC)"
endif
@echo "$(YELLOW)π Checking Keycloak DB connection...$(NC)"
@RETRY=0; \
while [ $$RETRY -lt 30 ]; do \
if $(DOCKER) exec $(KEYCLOAK_DB_CONTAINER_NAME) pg_isready -U keycloak >/dev/null 2>&1; then \
break; \
fi; \
printf "."; sleep 1; RETRY=$$((RETRY + 1)); \
done
@echo "$(GREEN) β
Keycloak DB ready$(NC)"
keycloak:
ifndef CI
ifeq ($(KEYCLOAK_UP),1)
@echo "$(YELLOW)π Starting Keycloak container...$(NC)"
$(COMPOSE) -f airborne_server/docker-compose.yml up -d keycloak
endif
else
@echo "$(YELLOW)Skipping keycloak container-setup in CI.$(NC)"
endif
@echo "$(YELLOW)π Checking Keycloak health...$(NC)"
@RETRY=0; \
while [ $$RETRY -lt 60 ]; do \
if curl -s -f $(KEYCLOAK_HOST_URL) >/dev/null 2>&1; then \
break; \
fi; \
printf "."; sleep 2; RETRY=$$((RETRY + 1)); \
done
@echo "$(GREEN) β
Keycloak ready$(NC)"
grafana:
ifndef CI
ifeq ($(GRAFANA_UP),1)
@echo "$(YELLOW)π Starting Grafana container...$(NC)"
$(COMPOSE) -f airborne_analytics_server/docker-compose.yml --env-file $(ENV_FILE_VM) up -d grafana
endif
else
@echo "$(YELLOW)Skipping grafana container-setup in CI.$(NC)"
endif
@echo "$(YELLOW)π Checking Grafana health...$(NC)"
@RETRY=0; \
while [ $$RETRY -lt 60 ]; do \
if curl -s -f $(GRAFANA_HOST_URL) >/dev/null 2>&1; then \
break; \
fi; \
printf "."; sleep 2; RETRY=$$((RETRY + 1)); \
done
@echo "$(GREEN) β
Grafana ready$(NC)"
victoria-metrics:
ifndef CI
ifeq ($(VICTORIA_METRICS_UP),1)
@echo "$(YELLOW)π Starting Victoria Metrics container...$(NC)"
$(COMPOSE) -f airborne_analytics_server/docker-compose.yml --env-file $(ENV_FILE_VM) up -d victoria-metrics
endif
else
@echo "$(YELLOW)Skipping victoria-metrics container-setup in CI.$(NC)"
endif
@echo "$(YELLOW)π Checking Victoria Metrics health...$(NC)"
@RETRY=0; \
while [ $$RETRY -lt 60 ]; do \
if curl -s -f $(VICTORIA_METRICS_HOST_URL) >/dev/null 2>&1; then \
break; \
fi; \
printf "."; sleep 2; RETRY=$$((RETRY + 1)); \
done
@echo "$(GREEN) β
Victoria Metrics ready$(NC)"
zookeeper:
ifndef CI
ifeq ($(ZOOKEEPER_UP),1)
@echo "$(YELLOW)π Starting Zookeeper container...$(NC)"
$(COMPOSE) -f airborne_analytics_server/docker-compose.yml --env-file $(ENV_FILE_KC) up -d zookeeper
endif
else
@echo "$(YELLOW)Skipping zookeeper container-setup in CI.$(NC)"
endif
@echo "$(YELLOW)π Checking Zookeeper health...$(NC)"
@RETRY=0; \
while [ $$RETRY -lt 60 ]; do \
if $(DOCKER) exec $(ZOOKEEPER_CONTAINER_NAME) echo ruok | nc localhost 2181 | grep imok >/dev/null 2>&1; then \
break; \
fi; \
printf "."; sleep 2; RETRY=$$((RETRY + 1)); \
done
@echo "$(GREEN) β
Zookeeper ready$(NC)"
kafka:
ifndef CI
ifeq ($(KAFKA_UP),1)
@echo "$(YELLOW)π Starting Kafka container...$(NC)"
$(COMPOSE) -f airborne_analytics_server/docker-compose.yml --env-file $(ENV_FILE_KC) up -d kafka
endif
else
@echo "$(YELLOW)Skipping kafka container-setup in CI.$(NC)"
endif
@echo "$(YELLOW)π Checking Kafka health...$(NC)"
@RETRY=0; \
while [ $$RETRY -lt 60 ]; do \
if $(DOCKER) exec $(KAFKA_CONTAINER_NAME) kafka-broker-api-versions --bootstrap-server localhost:9092 >/dev/null 2>&1; then \
break; \
fi; \
printf "."; sleep 2; RETRY=$$((RETRY + 1)); \
done
@echo "$(GREEN) β
Kafka ready$(NC)"
clickhouse:
ifndef CI
ifeq ($(CLICKHOUSE_UP),1)
@echo "$(YELLOW)π Starting ClickHouse container...$(NC)"
$(COMPOSE) -f airborne_analytics_server/docker-compose.yml --env-file $(ENV_FILE_KC) up -d clickhouse-server
endif
else
@echo "$(YELLOW)Skipping clickhouse container-setup in CI.$(NC)"
endif
@echo "$(YELLOW)π Checking ClickHouse health...$(NC)"
@RETRY=0; \
while [ $$RETRY -lt 60 ]; do \
if curl -s -f http://localhost:8123/ping >/dev/null 2>&1; then \
break; \
fi; \
printf "."; sleep 2; RETRY=$$((RETRY + 1)); \
done
@echo "$(GREEN) β
ClickHouse ready$(NC)"
kafka-ui:
ifndef CI
ifeq ($(KAFKA_UI_UP),1)
@echo "$(YELLOW)π§βπ» Starting Kafka UI container...$(NC)"
$(COMPOSE) -f airborne_analytics_server/docker-compose.yml --env-file $(ENV_FILE_KC) up -d kafka-ui
endif
else
@echo "$(YELLOW)Skipping kafka-ui container-setup in CI.$(NC)"
endif
@echo "$(YELLOW)π§βπ» Checking Kafka UI health...$(NC)"
@RETRY=0; \
while [ $$RETRY -lt 60 ]; do \
if curl -s -f http://localhost:8080/api/status >/dev/null 2>&1; then \
break; \
fi; \
printf "."; sleep 2; RETRY=$$((RETRY + 1)); \
done
@echo "$(GREEN) β
Kafka UI ready$(NC)"
node-dependencies:
cd airborne_dashboard && npm ci
cd airborne_server/docs_react && npm ci
dashboard:
cd airborne_dashboard && npm run dev
docs:
cd airborne_server/docs_react && npm run build:dev
# Parse USE_ENCRYPTED_SECRETS from command line: make setup USE_ENCRYPTED_SECRETS=true/false
USE_ENCRYPTED_SECRETS ?= true
SETUP_DEPS = env-file db superposition keycloak-db keycloak localstack node-dependencies
# ifdef CI
# SETUP_DEPS += test-tenant
# endif
setup:
@echo "$(YELLOW)π Running setup...$(NC)"
@echo "$(YELLOW)Starting infrastructure services...$(NC)"
$(MAKE) $(SETUP_DEPS)
@echo "$(GREEN)β
Setup complete!$(NC)"
@echo ""
@echo "$(YELLOW)Next steps:$(NC)"
@echo " make run # Start the server with encryption (default)"
@echo " make run USE_ENCRYPTED_SECRETS=false # Start without encryption"
@echo " make status # Check service status"
airborne-server:
@echo "$(YELLOW)Building airborne_server...$(NC)"
@cd airborne_server && cargo build $(CARGO_FLAGS) --bin airborne_server
superposition-init:
@echo "$(YELLOW)π Initializing Superposition...$(NC)"
@cd airborne_server && ./scripts/init-superposition.sh
keycloak-init:
@echo "$(YELLOW)π Initializing Keycloak...$(NC)"
@cd airborne_server && ./scripts/init-keycloak.sh
localstack-init:
@echo "$(YELLOW)βοΈ Initializing LocalStack...$(NC)"
@cd airborne_server && ./scripts/init-localstack.sh
db-migration:
@echo "$(YELLOW)ποΈ Running database migrations...$(NC)"
@if [ -f airborne_server/.env ]; then \
set -a; \
. airborne_server/.env; \
set +a; \
fi; \
if [ -z "$$DATABASE_URL" ] && [ -z "$$DB_URL" ]; then \
echo "$(YELLOW)DATABASE_URL and DB_URL not set by env file. Constructing with default password 'postgres' for migrations.$(NC)"; \
export DATABASE_URL="postgresql://$${DB_USER}:postgres@$${DB_HOST}:$${DB_PORT}/$${DB_NAME}"; \
elif [ -n "$$DB_URL" ]; then \
export DATABASE_URL="$$DB_URL"; \
fi; \
if (cd airborne_server && diesel migration run); then \
echo "$(GREEN)β
Database migrations completed$(NC)"; \
else \
echo "$(RED)β Database migrations failed$(NC)"; \
exit 1; \
fi
kill:
@echo "$(YELLOW)πͺ Killing existing airborne-server processes...$(NC)"
-@pkill -f airborne_server/target/debug/airborne_server 2>/dev/null || true
@echo "$(GREEN)β
Process cleanup completed$(NC)"
run: kill db superposition keycloak-db keycloak localstack
@echo "$(YELLOW)π Starting Airborne server...$(NC)"
@ENCRYPTION_MODE=$$(grep -E '^USE_ENCRYPTED_SECRETS=' airborne_server/.env 2>/dev/null | cut -d'=' -f2 || echo "$(USE_ENCRYPTED_SECRETS)"); \
echo "$(YELLOW)Encryption mode: $$ENCRYPTION_MODE$(NC)"; \
if [ "$$ENCRYPTION_MODE" = "true" ]; then \
echo "$(GREEN)π Encryption enabled (KMS + AES-GCM)$(NC)"; \
else \
echo "$(YELLOW)π Encryption disabled (plaintext mode)$(NC)"; \
fi; \
USE_ENCRYPTED_SECRETS=$$ENCRYPTION_MODE $(MAKE) superposition-init; \
USE_ENCRYPTED_SECRETS=$$ENCRYPTION_MODE $(MAKE) localstack-init; \
USE_ENCRYPTED_SECRETS=$$ENCRYPTION_MODE $(MAKE) keycloak-init; \
trap 'kill 0' INT TERM; \
$(MAKE) dashboard & \
$(MAKE) docs & \
cargo watch -w airborne_server/src -w airborne_server/Cargo.toml -w Cargo.toml -w Cargo.lock -s '$(MAKE) airborne-server && cd airborne_server && USE_ENCRYPTED_SECRETS='$$ENCRYPTION_MODE' ../target/debug/airborne_server' & \
wait
stop:
@echo "$(YELLOW)π Stopping all services...$(NC)"
@$(COMPOSE) -f airborne_server/docker-compose.yml down 2>/dev/null || true
@echo "$(GREEN)β
All services stopped.$(NC)"
cleanup:
@echo "$(YELLOW)π§Ή Cleaning up containers and volumes...$(NC)"
@$(COMPOSE) -f airborne_server/docker-compose.yml down -v --remove-orphans 2>/dev/null || true
@echo "$(YELLOW)ποΈ Removing environment file...$(NC)"
@rm -f airborne_server/.env
@echo "$(GREEN)β
Cleanup completed$(NC)"
test:
@echo "$(GREEN)π§ͺ Running full test suite...$(NC)"
@$(MAKE) clean
@echo "$(GREEN)Running tests...$(NC)"
@echo "$(YELLOW)TODO: Add actual test commands here$(NC)"
@echo "$(GREEN)β
Tests completed.$(NC)"
status:
@echo "$(GREEN)π Airborne System Status$(NC)"
@echo ""
@echo "$(YELLOW)ποΈ Infrastructure Services:$(NC)"
$(call service_status_simple,PostgreSQL,postgres)
$(call service_status_simple,Superposition,superposition)
$(call service_status_simple,Keycloak-DB,keycloak-db)
$(call service_status_simple,Keycloak,keycloak)
$(call service_status_simple,LocalStack,localstack)
@echo ""
@echo "$(YELLOW)π§ Initialization Status:$(NC)"
$(call init_status_simple,Environment,airborne_server/.env)
@echo ""
@echo "$(YELLOW)π³ Container Status:$(NC)"
@$(COMPOSE) -f airborne_server/docker-compose.yml ps --format "table {{.Service}}\t{{.State}}\t{{.Status}}" 2>/dev/null || echo "$(YELLOW)No containers running$(NC)"
@echo ""
frontend-check:
@echo "$(YELLOW)π Checking frontend code quality...$(NC)"
@cd airborne_dashboard && npm run check
@cd airborne_server/docs_react && npm run check
@echo "$(GREEN)Frontend checks completed$(NC)"
frontend-lint:
@echo "$(YELLOW)π Linting frontend code...$(NC)"
@cd airborne_dashboard && npm run lint
@cd airborne_server/docs_react && npm run lint
@echo "$(GREEN)Frontend linting completed$(NC)"
frontend-lint-fix:
@echo "$(YELLOW)π§ Fixing frontend lint issues...$(NC)"
@cd airborne_dashboard && npm run lint:fix
@cd airborne_server/docs_react && npm run lint:fix
@echo "$(GREEN)Frontend lint fixes completed$(NC)"
frontend-format:
@echo "$(YELLOW)β¨ Formatting frontend code...$(NC)"
@cd airborne_dashboard && npm run format
@cd airborne_server/docs_react && npm run format
@echo "$(GREEN)Frontend formatting completed$(NC)"
lint-fix: LINT_FLAGS += --fix --allow-dirty --allow-staged
lint-fix: lint frontend-lint-fix
check: FMT_FLAGS += --check
check: LINT_FLAGS += -- -Dwarnings
check: fmt lint frontend-check
fmt: frontend-format
cargo fmt $(FMT_FLAGS)
lint: frontend-lint
cargo clippy $(LINT_FLAGS)
commit: check
git commit $(COMMIT_FLAGS)
amend: COMMIT_FLAGS += --amend
amend: commit
amend-no-edit: COMMIT_FLAGS += --no-edit
amend-no-edit: amend
analytics-server:
@echo "$(YELLOW)Building analytics-server...$(NC)"
@cd airborne_analytics_server && cargo build $(CARGO_FLAGS) --bin airborne_analytics_server
run-kafka-clickhouse: analytics-env-file zookeeper kafka clickhouse kafka-ui
@echo "β³ Starting dev environment: Kafka + ClickHouse"
@cargo watch -w airborne_analytics_server/src -w airborne_analytics_server/Cargo.toml -w Cargo.toml -w Cargo.lock -s '$(MAKE) analytics-server && cd airborne_analytics_server && ../target/debug/airborne_analytics_server'
@echo "β
Development environment started with Kafka and ClickHouse!"
@echo " β’ Kafka UI: http://localhost:8080"
@echo " β’ ClickHouse: http://localhost:8123"
@echo " β’ Backend API: http://localhost:6400"
run-victoria-metrics: analytics-env-file grafana victoria-metrics
@echo "β³ Starting dev environment: Grafana + Victoria Metrics"
@cargo watch -w airborne_analytics_server/src -w airborne_analytics_server/Cargo.toml -w Cargo.toml -w Cargo.lock -s '$(MAKE) analytics-server && cd airborne_analytics_server && ../target/debug/airborne_analytics_server'
@echo "β
Development environment started with Grafana & Victoria Metrics!"
@echo " β’ Grafana: http://localhost:4000"
@echo " β’ Victoria Metrics: http://localhost:8428"
@echo " β’ Backend API: http://localhost:6400"
run-analytics: run-victoria-metrics
# ==============================================================================
# INTERNAL HELPER FUNCTIONS (not exposed to users)
# ==============================================================================
# Check if container is running
define is_container_running
$(shell $(DOCKER) ps --filter "name=$(1)" --filter "status=running" --format "{{.Names}}" 2>/dev/null)
endef
# Simplified status display
define service_status_simple
@printf " %-12s " "$(1):"; \
if [ -n "$(call is_container_running,$(2))" ]; then \
printf "$(GREEN)β$(NC) Running"; \
else \
printf "$(RED)β$(NC) Stopped"; \
fi; \
echo ""
endef
# Simplified init status
define init_status_simple
@printf " %-12s " "$(1):"; \
if [ -f $(2) ]; then \
printf "$(GREEN)β
$(NC) Ready"; \
else \
printf "$(YELLOW)β³$(NC) Pending"; \
fi; \
echo ""
endef
smithy-clean:
rm -rf smithy/output
smithy-build:
cd smithy && smithy build
smithy-clean-build: smithy-clean smithy-build
smithy-clients: smithy-clean-build
rm -rf airborne_server_clients/javascript/sdk
mkdir -p airborne_server_clients/javascript/sdk
rm -rf airborne_server_clients/model
mkdir -p airborne_server_clients/model
# git restore airborne_server_clients/javascript/sdk/README.md
cp -r $(SMITHY_BUILD_SRC)/typescript-client-codegen/*\
airborne_server_clients/javascript/sdk
git restore airborne_server_clients/javascript/sdk/LICENSE
cp -f $(SMITHY_BUILD_SRC)/model/*\
airborne_server_clients/model
@for d in $(SMITHY_BUILD_SRC)/*-client-codegen; do \
[ -d "$$d" ] || continue; \
[[ "$$d" =~ "typescript" ]] && continue; \
name=$$(basename "$$d" -client-codegen); \
mkdir -p "airborne_server_clients/$$name"; \
cp -r "$$d"/* "airborne_server_clients/$$name"; \
done
git apply smithy/patches/*.patch
generate-cli: smithy-clients
cd airborne_server_clients/javascript/sdk && npm install && npm run build
find airborne-core-cli -mindepth 1 ! -name 'CHANGELOG.md' -exec rm -rf {} +
cd smithy-cli-generator && npm install
node smithy-cli-generator/src/index.js \
--smithyBuildJSONPath smithy/smithy-build.json \
--smithyTypescriptSdk file:../airborne_server_clients/javascript/sdk \
--cliName "airborne-core-cli" \
--cliDescription "Command-line interface for Airborne OTA operations" \
--buildPath . \
--namespace io.airborne.server \
--service Airborne \
--smithyModelJSONPath airborne_server_clients/model/model.json \
--plugin typescript-client-codegen
@echo "$(YELLOW)Adding repository field to airborne-core-cli/package.json...$(NC)"
@sed -i.bak '/"dependencies": {/i\
\ "repository": {\
\ "type": "git",\
\ "url": "git+https://github.com/juspay/airborne.git"\
\ },' airborne-core-cli/package.json && rm -f airborne-core-cli/package.json.bak
cd airborne-core-cli && npm install