-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
212 lines (154 loc) · 6.66 KB
/
Copy pathMakefile
File metadata and controls
212 lines (154 loc) · 6.66 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
# NeuraMemory-AI Makefile
# Shortcuts for common Docker Compose and development commands
.PHONY: help build up down restart logs ps clean test dev dev-down prod-build prod-up prod-down dev-logs prod-logs shell-server shell-postgres backup
# Default target
.DEFAULT_GOAL := help
# Variables
COMPOSE_FILES := -f docker-compose.yml
DEV_COMPOSE_FILES := -f docker-compose.yml -f docker-compose.dev.yml
##@ General
help: ## Display this help message
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
##@ Production Deployment
prod-build: ## Build production images
docker compose $(COMPOSE_FILES) build
prod-up: ## Start production services (detached)
docker compose $(COMPOSE_FILES) up -d
prod-down: ## Stop production services
docker compose $(COMPOSE_FILES) down
prod-restart: prod-down prod-up ## Restart production services
prod-logs: ## View production logs (follow)
docker compose $(COMPOSE_FILES) logs -f
prod-ps: ## Show production service status
docker compose $(COMPOSE_FILES) ps
##@ Development
dev: ## Start development environment with hot-reload
docker compose $(DEV_COMPOSE_FILES) up --build
dev-build: ## Build development images
docker compose $(DEV_COMPOSE_FILES) build
dev-up: ## Start development services (detached)
docker compose $(DEV_COMPOSE_FILES) up -d
dev-down: ## Stop development services
docker compose $(DEV_COMPOSE_FILES) down
dev-restart: dev-down dev-up ## Restart development services
dev-logs: ## View development logs (follow)
docker compose $(DEV_COMPOSE_FILES) logs -f
dev-logs-server: ## View server logs only
docker compose $(DEV_COMPOSE_FILES) logs -f server
dev-logs-client: ## View client logs only
docker compose $(DEV_COMPOSE_FILES) logs -f client
##@ Database Management
db-start: ## Start only PostgreSQL and Qdrant
docker compose $(COMPOSE_FILES) up -d postgres qdrant
db-stop: ## Stop PostgreSQL and Qdrant
docker compose $(COMPOSE_FILES) stop postgres qdrant
db-logs: ## View database logs
docker compose $(COMPOSE_FILES) logs -f postgres qdrant
psql-shell: ## Open PostgreSQL shell
docker compose $(COMPOSE_FILES) exec postgres psql -U neuramemory
qdrant-health: ## Check Qdrant health
@curl -s http://localhost:6333/health | jq '.'
##@ Testing & Quality
test: ## Run API tests (requires running server)
cd server && ./test-routes.sh
test-verbose: ## Run API tests with verbose output
cd server && VERBOSE=true ./test-routes.sh
lint-server: ## Run ESLint on server code
docker compose $(DEV_COMPOSE_FILES) exec server npm run lint
format-server: ## Format server code with Prettier
docker compose $(DEV_COMPOSE_FILES) exec server npm run format
build-server: ## Build TypeScript (check for errors)
docker compose $(DEV_COMPOSE_FILES) exec server npm run build
##@ Utilities
shell-server: ## Open shell in server container
docker compose $(COMPOSE_FILES) exec server sh
shell-postgres: ## Open shell in PostgreSQL container
docker compose $(COMPOSE_FILES) exec postgres sh
shell-qdrant: ## Open shell in Qdrant container
docker compose $(COMPOSE_FILES) exec qdrant sh
ps: ## Show all running containers
docker compose $(COMPOSE_FILES) ps
stats: ## Show container resource usage
docker stats
##@ Cleanup
clean: ## Stop and remove all containers
docker compose $(COMPOSE_FILES) down
clean-volumes: ## Stop and remove containers + volumes (⚠️ deletes data)
@echo "⚠️ WARNING: This will delete all data in PostgreSQL and Qdrant!"
@read -p "Are you sure? [y/N] " -n 1 -r; \
echo; \
if [[ $$REPLY =~ ^[Yy]$$ ]]; then \
docker compose $(COMPOSE_FILES) down -v; \
fi
clean-all: ## Remove containers, volumes, and images (⚠️ complete reset)
@echo "⚠️ WARNING: This will delete everything and rebuild from scratch!"
@read -p "Are you sure? [y/N] " -n 1 -r; \
echo; \
if [[ $$REPLY =~ ^[Yy]$$ ]]; then \
docker compose $(COMPOSE_FILES) down -v --rmi all; \
docker system prune -f; \
fi
prune: ## Remove unused Docker resources
docker system prune -f
##@ Backup & Restore
backup-postgres: ## Backup PostgreSQL to backups/ directory
@mkdir -p backups
@echo "Creating PostgreSQL backup..."
@docker compose $(COMPOSE_FILES) exec -T postgres pg_dump -U neuramemory neuramemory > backups/postgres_$$(date +%Y%m%d_%H%M%S).sql
@echo "✓ Backup complete: backups/postgres_$$(date +%Y%m%d_%H%M%S).sql"
restore-postgres: ## Restore PostgreSQL from latest backup
@LATEST=$$(ls -t backups/postgres_*.sql 2>/dev/null | head -1); \
if [ -z "$$LATEST" ]; then \
echo "❌ No backup files found in backups/"; \
exit 1; \
fi; \
echo "Restoring from $$LATEST..."; \
docker compose $(COMPOSE_FILES) exec -T postgres psql -U neuramemory neuramemory < $$LATEST; \
echo "✓ Restore complete"
##@ Quick Actions
up: prod-up ## Alias for prod-up
down: prod-down ## Alias for prod-down
restart: prod-restart ## Alias for prod-restart
logs: prod-logs ## Alias for prod-logs
rebuild: ## Rebuild and restart production services
docker compose $(COMPOSE_FILES) up -d --build
dev-rebuild: ## Rebuild and restart development services
docker compose $(DEV_COMPOSE_FILES) up -d --build
##@ Information
info: ## Show project information
@echo "\n📦 NeuraMemory-AI Docker Environment\n"
@echo "Services:"
@docker compose $(COMPOSE_FILES) ps
@echo "\nVolumes:"
@docker volume ls | grep neuramemory || echo "No volumes found"
@echo "\nNetworks:"
@docker network ls | grep neuramemory || echo "No networks found"
@echo "\nImages:"
@docker images | grep neuramemory || echo "No images found"
endpoints: ## Show service endpoints
@echo "\n🌐 Service Endpoints:\n"
@echo " Frontend: http://localhost:5173"
@echo " API: http://localhost:3000"
@echo " API Docs: http://localhost:3000/api/v1"
@echo " PostgreSQL: postgresql://localhost:5432"
@echo " Qdrant: http://localhost:6333"
@echo " Qdrant UI: http://localhost:6333/dashboard"
@echo ""
check-env: ## Verify required environment variables
@echo "Checking environment configuration...\n"
@if [ ! -f server/.env ]; then \
echo "❌ server/.env not found"; \
echo " Run: cp server/.env.example server/.env"; \
exit 1; \
fi
@echo "✓ server/.env exists"
@cd server && node -e "require('dotenv').config(); \
const required = ['DATABASE_URL', 'QDRANT_URL', 'OPENROUTER_API_KEY', 'JWT_SECRET']; \
let missing = []; \
required.forEach(key => { if (!process.env[key]) missing.push(key); }); \
if (missing.length > 0) { \
console.log('❌ Missing required variables:', missing.join(', ')); \
process.exit(1); \
} else { \
console.log('✓ All required variables present'); \
}"