-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
157 lines (127 loc) · 3.75 KB
/
Copy pathMakefile
File metadata and controls
157 lines (127 loc) · 3.75 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
SHELL := /bin/bash
.PHONY: seed tools migrate compose env rebuild-apps rebuild-app recreate-apps recreate-app atlas hermes zeus apps config sync-dashboards infra
# Go Binaries (optional - for production tool binaries)
GO_BUILD = go build
BIN_DIR = ./bin/
TOOLS_DIR = ./tools/
default: tools atlas hermes zeus
tools:
mkdir -p $(BIN_DIR)
$(GO_BUILD) -o $(BIN_DIR) $(TOOLS_DIR)...
# Docker Services
DOCKER_COMPOSE = docker compose -f docker-compose.yml --env-file ./.env
# Development Commands (Recommended)
dev:
@echo "Starting RaidHub-Services development environment..."
@echo "This provides hot reload, service orchestration, and monitoring"
@echo "Access Tilt UI at: http://localhost:10350"
@echo "Press Ctrl+C to stop"
tilt up
up:
$(DOCKER_COMPOSE) up -d
down:
$(DOCKER_COMPOSE) down
restart:
$(DOCKER_COMPOSE) restart
stop:
$(DOCKER_COMPOSE) stop
ps:
$(DOCKER_COMPOSE) ps
infra:
$(DOCKER_COMPOSE) up -d postgres rabbitmq clickhouse prometheus loki promtail grafana
apps-dev:
$(DOCKER_COMPOSE) build hermes atlas zeus
$(DOCKER_COMPOSE) up -d --force-recreate hermes atlas zeus
atlas-dev:
$(DOCKER_COMPOSE) build atlas
$(DOCKER_COMPOSE) up -d --force-recreate atlas
atlas:
go build -o ./bin/atlas ./apps/atlas/
hermes-dev:
$(DOCKER_COMPOSE) build hermes
$(DOCKER_COMPOSE) up -d --force-recreate hermes
hermes:
go build -o ./bin/hermes ./apps/hermes/
zeus-dev:
$(DOCKER_COMPOSE) build zeus
$(DOCKER_COMPOSE) up -d --force-recreate zeus
zeus:
go build -o ./bin/zeus ./apps/zeus/
cron-dev:
$(DOCKER_COMPOSE) build cron
$(DOCKER_COMPOSE) up -d --force-recreate cron
cron:
crontab ./infrastructure/cron/jobs.crontab
# Database management
migrate: migrate-postgres migrate-clickhouse
@echo "✓ All migrations complete"
migrate-%:
@case "$*" in \
postgres) \
echo "Running PostgreSQL migrations..."; \
go run ./infrastructure/postgres/migrate/; \
;; \
clickhouse) \
echo "Running ClickHouse migrations..."; \
go run ./infrastructure/clickhouse/migrate/; \
;; \
*) \
echo "Unknown database: $*"; \
echo "Available options: postgres, clickhouse"; \
exit 1; \
;; \
esac
seed:
go run ./tools/seed/
config:
@echo "✅ Configuration files are now static - no generation needed"
# Sync Grafana dashboards from UI back to infrastructure files
sync-dashboards:
@echo "📥 Syncing Grafana dashboards..."
@./infrastructure/grafana/sync-dashboards.sh
# Environment file management
env:
@if [ ! -f .env ]; then \
echo "📝 Creating .env file from example.env..."; \
cp example.env .env; \
echo "✅ .env file created"; \
else \
echo "✅ .env file already exists"; \
fi
@if [ -f example.env ] && [ -f .env ]; then \
missing_keys=(); \
missing_values=(); \
added_count=0; \
while IFS='=' read -r key value || [ -n "$$key" ]; do \
key=$$(echo "$$key" | xargs); \
[[ "$$key" =~ ^# ]] && continue; \
[[ -z "$$key" ]] && continue; \
value=$${value%$$'\r'}; \
value=$$(echo "$$value" | xargs); \
if [ -z "$$value" ]; then \
continue; \
fi; \
grep_result=$$(grep "^$$key=" .env 2>/dev/null || echo ""); \
if [ -z "$$grep_result" ]; then \
missing_keys+=("$$key"); \
missing_values+=("$$key=$$value"); \
added_count=$$((added_count + 1)); \
fi; \
done < example.env; \
if [ $${#missing_keys[@]} -gt 0 ]; then \
echo "" >> .env; \
echo "# Keys automatically added by make env on $$(date)" >> .env; \
for entry in "$${missing_values[@]}"; do \
echo "$$entry" >> .env; \
done; \
echo "📝 Added $$added_count missing key(s) to .env"; \
for key in "$${missing_keys[@]}"; do \
echo " + $$key"; \
done; \
else \
echo "✅ All keys from example.env are present in .env"; \
fi; \
fi
clean:
$(DOCKER_COMPOSE) down
rm -rf $(BIN_DIR) volumes/ logs/ .raidhub/