-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
292 lines (259 loc) · 14.5 KB
/
Copy pathMakefile
File metadata and controls
292 lines (259 loc) · 14.5 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
# ═══════════════════════════════════════════════════════════════════════════
# Garamatic Meta-Repo — Makefile
# ═══════════════════════════════════════════════════════════════════════════
# Common commands for managing the entire microservices ecosystem.
#
# Usage:
# make setup # Initialize submodules and env
# make up # Start the demo stack
# make down # Stop the demo stack
# make test # Run integration tests
# make update # Pull latest from all submodules
# make pull # Pull root repo and submodules
# make push # Push root repo and submodule commits
# make status # Show current submodule commits
# ═══════════════════════════════════════════════════════════════════════════
.PHONY: setup up down test update pull push sync status logs lint
# ─── Load .env ─────────────────────────────────────────────────────────────
ifneq (,$(wildcard .env))
include .env
export
endif
# ─── Setup ─────────────────────────────────────────────────────────────────
setup:
@echo "📦 Initializing submodules..."
git submodule update --init --recursive
@echo "📋 Copying environment template..."
cp -n .env.example .env 2>/dev/null || echo " .env already exists"
@echo "✅ Setup complete. Run 'make up' to start the stack."
# ─── Docker Compose (Demo Environment) ─────────────────────────────────────
COMPOSE_FILE := demo/docker-compose.yml
COMPOSE_TUNNEL := docker-compose.tunnel.yml
MONITOR_SERVICES := prometheus loki promtail tempo cadvisor grafana health-dashboard
TENANT ?= desgoffe
export TENANT_CONFIG = $(CURDIR)/demo/config
up:
@echo "🚀 Starting Garamatic stack (tenant: $(TENANT))..."
TENANT=$(TENANT) TENANT_CONFIG=$(TENANT_CONFIG) docker compose -f $(COMPOSE_FILE) --env-file .env up --build -d
@echo ""
@echo " Services:"
@echo " • Showcase → http://localhost:8092"
@echo " • Ticket Masala → http://localhost:8085"
@echo " • Gatekeeper → http://localhost:8086"
@echo " • Mailing Service → http://localhost:8087"
@echo " • Agentic API → http://localhost:3001"
@echo " • Odoo Bridge → http://localhost:8089/health"
@echo " • Garamatic Web → http://localhost:8090"
@echo " • Masala Web → http://localhost:8091"
@echo " • Portal (Desgoffe) → http://localhost:8093"
@echo " • Odoo ERP → http://localhost:8069 (admin/admin)"
@echo " • LLama.cpp LLM → http://localhost:11434"
@echo " • RabbitMQ Mgmt → http://localhost:15672 (guest/guest)"
@echo " • Mailhog UI → http://localhost:8025"
@echo ""
@echo " Observability:"
@echo " • Grafana Dashboard → http://localhost:3000 (admin/${GRAFANA_ADMIN_PASSWORD:-admin})"
@echo " • Prometheus Metrics → http://localhost:9090"
@echo " • Loki Logs → http://localhost:3100"
@echo " • Tempo Traces → http://localhost:3200"
@echo " • cAdvisor Containers → http://localhost:8094"
@echo " • Health Dashboard → http://localhost:3003"
@echo ""
@echo " 💡 Run 'make pull-model' to download the local LLM"
down:
@echo "🛑 Stopping Garamatic stack..."
docker compose -f $(COMPOSE_FILE) down -v
pull-model:
@echo "📥 Models are bundled locally in ./models/"
@echo " Current model: qwen3.5-2b-q4_k_m.gguf (1.9GB)"
@echo "✅ LLama.cpp server loads the model at startup. No manual pull needed."
dev:
@echo "🚀 Starting Garamatic stack (attached, tenant: $(TENANT))..."
TENANT=$(TENANT) TENANT_CONFIG=$(TENANT_CONFIG) docker compose -f $(COMPOSE_FILE) up --build
rebuild:
@echo "🔨 Rebuilding ticket-masala image (no cache)..."
TENANT=$(TENANT) TENANT_CONFIG=$(TENANT_CONFIG) docker compose -f $(COMPOSE_FILE) build --no-cache ticket-masala
@echo "✅ Rebuild complete. Run 'make up' to start."
logs:
docker compose -f $(COMPOSE_FILE) logs -f
# ─── Testing ───────────────────────────────────────────────────────────────
test:
@echo "🧪 Running integration tests..."
docker compose -f integration-tests/docker/docker-compose.test.yml up \
--build --abort-on-container-exit
test-local:
@echo "🧪 Running integration tests against local services..."
cd integration-tests && npm test
# ─── Submodule Management ──────────────────────────────────────────────────
update:
@echo "⬆️ Updating all submodules to latest remote..."
git submodule update --remote
@echo ""
@echo "⚠️ Review changes before committing!"
pull:
@echo "⬇️ Pulling root repo and submodules..."
@scripts/pull.sh
push:
@echo "⬆️ Pushing root repo and submodule commits..."
@scripts/push.sh
sync: pull push
@echo "✅ Repo and submodules synced."
status:
@echo "📊 Submodule status:"
@git submodule status
bump:
@echo "🔖 Bumping all submodules to latest and committing..."
git submodule update --remote
git add -A
git commit -m "bump: update all submodules to latest" || echo "No changes to commit"
# ─── Development ───────────────────────────────────────────────────────────
pre-commit-install:
@echo "🔧 Installing pre-commit..."
@uv tool install pre-commit 2>/dev/null || true
@pre-commit install
@echo "✅ Pre-commit hooks installed. Run 'pre-commit run --all-files' to test."
lint:
@echo "🔍 Running code quality checks across services..."
@echo " Python (agentic-service)..."
@uv run --directory agentic-service ruff check .
@echo " Node.js (masala-web)..."
@cd masala-web && npm run lint
@echo "✅ Lint checks complete."
# ─── Monitoring ────────────────────────────────────────────────────────────
monitor-up:
@echo "📊 Starting observability stack (Prometheus + Loki + Tempo + Grafana)..."
docker compose -f $(COMPOSE_FILE) up -d $(MONITOR_SERVICES)
@echo ""
@echo " Observability Services:"
@echo " • Grafana Dashboard → http://localhost:3000 (admin/${GRAFANA_ADMIN_PASSWORD:-admin})"
@echo " • Prometheus Metrics → http://localhost:9090"
@echo " • Loki Logs → http://localhost:3100"
@echo " • Tempo Traces → http://localhost:3200"
@echo " • cAdvisor Containers → http://localhost:8094"
@echo " • Health Dashboard → http://localhost:3003"
@echo ""
@echo " 💡 Dashboards: Garamatic — Observability, Logs, Traces"
@echo " 💡 Default login: admin / ${GRAFANA_ADMIN_PASSWORD:-admin}"
monitor-down:
@echo "🛑 Stopping monitoring stack..."
docker compose -f $(COMPOSE_FILE) stop $(MONITOR_SERVICES)
docker compose -f $(COMPOSE_FILE) rm -f $(MONITOR_SERVICES)
monitor-logs:
docker compose -f $(COMPOSE_FILE) logs -f $(MONITOR_SERVICES)
# ─── Cloudflare Tunnel ───────────────────────────────────────────────────
# Exposes the demo stack via a locally managed Cloudflare Tunnel.
# Routes are configured in cloudflared/config.yml (local file).
# Dashboard modifications are not possible for this tunnel.
#
# First time setup:
# 1. Install cloudflared CLI: https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/downloads/
# 2. Authenticate: cloudflared tunnel login
# 3. Create tunnel: cloudflared tunnel create garamatic
# 4. Add to .env: CLOUDFLARE_TUNNEL_ID=<tunnel-id>
# 5. Add to .env: CLOUDFLARE_DOMAIN=your-domain.com
# 6. Run: make tunnel-setup
# 7. Run: make tunnel-up
tunnel-setup:
@echo "🔧 Generating Cloudflare Tunnel config..."
@./scripts/setup-tunnel.sh
tunnel-up:
@echo "🌐 Starting Cloudflare Tunnel..."
@if [ -z "$(CLOUDFLARE_TUNNEL_ID)" ]; then \
echo "❌ CLOUDFLARE_TUNNEL_ID not set in .env"; \
echo " Create a tunnel: cloudflared tunnel create garamatic"; \
echo " Add to .env: echo 'CLOUDFLARE_TUNNEL_ID=<id>' >> .env"; \
echo " Then run: make tunnel-setup"; \
exit 1; \
fi
@if [ ! -f "cloudflared/credentials.json" ]; then \
echo "❌ cloudflared/credentials.json not found."; \
echo " Run: make tunnel-setup"; \
exit 1; \
fi
@if [ ! -f "cloudflared/config.yml" ]; then \
echo "❌ cloudflared/config.yml not found."; \
echo " Run: make tunnel-setup"; \
exit 1; \
fi
@NETWORK=$$(docker network ls --filter name=garamatic_demo_net --format '{{.Name}}' | head -1); \
[ -z "$$NETWORK" ] && { echo "❌ Demo network not found. Run 'make up' first."; exit 1; }; \
echo "🔗 Attaching to network: $$NETWORK"; \
echo " Tunnel ID: $(shell echo '$(CLOUDFLARE_TUNNEL_ID)' | cut -c1-20)..."; \
DEMO_NETWORK=$$NETWORK docker compose -f $(COMPOSE_TUNNEL) up -d
@echo " Exposing (from cloudflared/config.yml):"
@echo " • Portal → portal.$(CLOUDFLARE_DOMAIN) → http://portal:80"
@echo " • Garamatic Web → web.$(CLOUDFLARE_DOMAIN) → http://garamatic-web:8080"
@echo " • Masala Web → masala.$(CLOUDFLARE_DOMAIN) → http://masala-web:8080"
@echo " • Showcase → showcase.$(CLOUDFLARE_DOMAIN) → http://showcase:80"
@echo " • Gatekeeper → api.$(CLOUDFLARE_DOMAIN) → http://gatekeeper-api:8080"
@echo " • Ticket Masala → tickets.$(CLOUDFLARE_DOMAIN) → http://ticket-masala:8080"
@echo " • Agentic → agentic.$(CLOUDFLARE_DOMAIN) → http://agentic-service:3001"
@echo " • Odoo Bridge → odoo-bridge.$(CLOUDFLARE_DOMAIN) → http://odoo-integration:8080"
@echo " • Mailhog → mailhog.$(CLOUDFLARE_DOMAIN) → http://mailhog:8025"
@echo " • RabbitMQ → rabbitmq.$(CLOUDFLARE_DOMAIN) → http://rabbitmq:15672"
@echo " • Odoo ERP → odoo.$(CLOUDFLARE_DOMAIN) → http://odoo:8069"
@echo " • MCP → mcp.$(CLOUDFLARE_DOMAIN) → http://agentic-mcp:3001"
@echo " • Monitor → monitor.$(CLOUDFLARE_DOMAIN) → http://grafana:3000"
@echo " • Prometheus → prometheus.$(CLOUDFLARE_DOMAIN) → http://prometheus:9090"
@echo " • Loki → loki.$(CLOUDFLARE_DOMAIN) → http://loki:3100"
@echo " • Tempo → tempo.$(CLOUDFLARE_DOMAIN) → http://tempo:3200"
@echo ""
@echo "✅ Tunnel container started."
@echo " 💡 Check status: make tunnel-status"
@echo " 💡 View logs: make tunnel-logs"
@echo " 💡 Add DNS: cloudflared tunnel route dns <id> <subdomain>"
tunnel-down:
@echo "🛑 Stopping Cloudflare Tunnel..."
@docker compose -f $(COMPOSE_TUNNEL) down
tunnel-logs:
@docker compose -f $(COMPOSE_TUNNEL) logs -f
tunnel-status:
@echo "📊 Cloudflare Tunnel status:"
@docker compose -f $(COMPOSE_TUNNEL) ps
# ─── Full Stack (App + Monitoring) ─────────────────────────────────────────
# stack-up and stack-down are aliases — make up / make down now handle everything
stack-up: up
stack-down: down
# ─── Backup & Restore ──────────────────────────────────────────────────────
backup:
@echo "💾 Creating backup..."
@scripts/backup.sh
restore:
@echo "📦 Available backups:"
@ls -1 backups/*_* 2>/dev/null | grep -oE '[0-9]{8}_[0-9]{6}' | sort -u | head -10 || echo "No backups found"
@echo ""
@echo "Usage: make restore TIMESTAMP=YYYYMMDD_HHMMSS"
@if [ -n "$(TIMESTAMP)" ]; then scripts/restore.sh $(TIMESTAMP); fi
# ─── Help ──────────────────────────────────────────────────────────────────
help:
@echo "Garamatic Meta-Repo Commands"
@echo ""
@echo " make setup Initialize submodules and env"
@echo " make up Start the demo stack (detached)"
@echo " make up TENANT=default Start with generic config"
@echo " make dev Start the demo stack (attached)"
@echo " make pull-model Show current bundled model info"
@echo " make down Stop and remove the demo stack"
@echo " make logs Tail Docker logs"
@echo " make test Run integration tests in Docker"
@echo " make test-local Run integration tests against local services"
@echo " make monitor-up Start monitoring stack (Grafana + health dashboard)"
@echo " make monitor-down Stop monitoring stack"
@echo " make monitor-logs Tail monitoring logs"
@echo " make tunnel-setup Generate tunnel config + copy credentials"
@echo " make tunnel-up Start Cloudflare Tunnel (Docker container)"
@echo " make tunnel-down Stop Cloudflare Tunnel"
@echo " make tunnel-status Check tunnel container status"
@echo " make tunnel-logs Tail Cloudflare Tunnel logs"
@echo " make stack-up Start full stack (services + monitoring)"
@echo " make stack-down Stop full stack"
@echo " make backup Create backup of all volumes and databases"
@echo " make restore Restore from backup (TIMESTAMP=YYYYMMDD_HHMMSS)"
@echo " make update Pull latest commits for all submodules"
@echo " make pull Pull root repo and submodules"
@echo " make push Push root repo and submodule commits"
@echo " make sync Pull then push root repo and submodules"
@echo " make status Show current submodule commits"
@echo " make bump Update submodules and commit the root repo"
@echo " make lint Run code quality checks"
@echo " make help Show this help message"