-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
192 lines (168 loc) Β· 6.04 KB
/
Makefile
File metadata and controls
192 lines (168 loc) Β· 6.04 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
.PHONY: help start stop restart rebuild logs logs-app status health setup build run dev test fmt check lint clean clean-all infra
help: ## Show this help
@echo "π§ BrainStack - Makefile Commands"
@echo ""
@echo "Quick Start:"
@echo " make start - Setup and start all Docker services"
@echo " make stop - Stop all services"
@echo " make logs - View all logs"
@echo ""
@echo "Available commands:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'
# =============================================================================
# Setup & Start
# =============================================================================
setup: ## Setup config files and directories
@echo "π Creating directories..."
@mkdir -p config data assets
@if [ ! -f config/config.json ]; then \
if [ -f config/config.example.json ]; then \
cp config/config.example.json config/config.json; \
echo "β
Created config/config.json from example"; \
else \
echo '{"database_url":"sqlite://data/brainstack.db","sources_config_path":"config/sources.json"}' > config/config.json; \
echo "β
Created config/config.json with defaults"; \
fi \
fi
@if [ ! -f config/sources.json ]; then \
if [ -f config/sources.example.json ]; then \
cp config/sources.example.json config/sources.json; \
echo "β
Created config/sources.json from example"; \
else \
echo '{"sources":[]}' > config/sources.json; \
echo "β
Created config/sources.json with empty sources"; \
fi \
fi
@echo "β
Setup complete!"
start: setup ## Start all Docker services (recommended for first-time users)
@echo "π³ Starting BrainStack..."
@echo ""
@if ! command -v docker >/dev/null 2>&1; then \
echo "β Docker is not installed. Please install Docker first."; \
exit 1; \
fi
@if ! command -v docker-compose >/dev/null 2>&1; then \
echo "β Docker Compose is not installed. Please install Docker Compose first."; \
exit 1; \
fi
@docker-compose up -d
@echo ""
@echo "β³ Waiting for services to start..."
@sleep 5
@echo ""
@if curl -s http://localhost:3000 >/dev/null 2>&1; then \
echo "β
BrainStack is running!"; \
echo ""; \
echo "π Application: http://localhost:3000"; \
echo "π Minio Console: http://localhost:9001 (minioadmin/minioadmin)"; \
echo "π Qdrant UI: http://localhost:6333/dashboard"; \
echo ""; \
echo "π View logs: make logs"; \
echo "π Stop services: make stop"; \
else \
echo "β οΈ Services started but application may still be initializing..."; \
echo "Please wait a moment and check http://localhost:3000"; \
echo ""; \
echo "View logs with: make logs-app"; \
fi
stop: ## Stop all Docker services
@echo "π Stopping all services..."
@docker-compose down
restart: ## Restart all Docker services
@echo "π Restarting all services..."
@docker-compose restart
rebuild: ## Rebuild and restart BrainStack app only
@echo "π¨ Rebuilding BrainStack app..."
@docker-compose up -d --build brainstack
@echo "β
BrainStack app rebuilt and restarted"
# =============================================================================
# Development
# =============================================================================
infra: setup ## Start infrastructure services only (for local Rust development)
@echo "π³ Starting infrastructure services only..."
@docker-compose up -d postgres redis qdrant minio
@echo "β
Infrastructure ready!"
@echo ""
@echo "Run the app locally with: make run"
build: ## Build the Rust application
@echo "π¨ Building Rust binary..."
@cargo build --release
@echo "β
Build complete: target/release/brainstack"
run: ## Run the application locally (requires infrastructure)
@echo "π Running BrainStack locally..."
@cargo run
dev: ## Run the application in development mode with auto-reload
@echo "π¨βπ» Starting development mode with auto-reload..."
@cargo watch -x run
test: ## Run tests
@echo "π§ͺ Running tests..."
@cargo test
fmt: ## Format code
@echo "β¨ Formatting code..."
@cargo fmt
check: ## Run cargo check
@echo "π Running cargo check..."
@cargo check
lint: ## Run clippy linter
@echo "π Running clippy..."
@cargo clippy -- -D warnings
# =============================================================================
# Monitoring
# =============================================================================
logs: ## View all Docker logs
@docker-compose logs -f
logs-app: ## View BrainStack app logs only
@docker-compose logs -f brainstack
status: ## Show Docker service status
@docker-compose ps
health: ## Check service health
@echo "π₯ Checking service health..."
@echo ""
@echo "App (port 3000):"
@if curl -s -o /dev/null http://localhost:3000; then \
echo " β
Healthy"; \
else \
echo " β Not responding"; \
fi
@echo ""
@echo "PostgreSQL (port 5432):"
@if docker-compose exec -T postgres pg_isready >/dev/null 2>&1; then \
echo " β
Healthy"; \
else \
echo " β Not responding"; \
fi
@echo ""
@echo "Redis (port 6379):"
@if docker-compose exec -T redis redis-cli ping >/dev/null 2>&1; then \
echo " β
Healthy"; \
else \
echo " β Not responding"; \
fi
@echo ""
@echo "Qdrant (port 6333):"
@if curl -s -o /dev/null http://localhost:6333; then \
echo " β
Healthy"; \
else \
echo " β Not responding"; \
fi
@echo ""
@echo "Minio (port 9000):"
@if curl -s -o /dev/null http://localhost:9000/minio/health/live; then \
echo " β
Healthy"; \
else \
echo " β Not responding"; \
fi
# =============================================================================
# Cleanup
# =============================================================================
clean: ## Stop services and clean build artifacts
@echo "π§Ή Cleaning up..."
@docker-compose down
@cargo clean
@echo "β
Cleanup complete"
clean-all: ## Stop services, remove volumes, and clean build artifacts
@echo "π§Ή Full cleanup (including volumes)..."
@docker-compose down -v
@cargo clean
@rm -rf target/
@echo "β
Full cleanup complete"