Skip to content

Commit 39a6d16

Browse files
committed
refactor: simplify Makefile for better usability
- Add color support for better visibility - Remove complex status checks - Run container in detached mode by default - Add clear start and completion messages - Improve help message format (cherry picked from commit 781347d39225f9d11754017cd9ffd8b5b4fa6224)
1 parent 8e7d5e2 commit 39a6d16

File tree

1 file changed

+47
-8
lines changed

1 file changed

+47
-8
lines changed

Makefile

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,53 @@
1-
run:
2-
# Kill any process occupying port 5001
3-
@if lsof -i :5001; then \
1+
# Colors for better visibility
2+
GREEN := \033[0;32m
3+
RED := \033[0;31m
4+
NC := \033[0m # No Color
5+
6+
# Include environment variables from .env
7+
include .env
8+
export
9+
10+
.PHONY: help init build run stop logs test
11+
12+
help: ## Show this help message
13+
@echo "CodeQuery Core - Quick Start Guide"
14+
@echo "Usage:"
15+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " make %-10s %s\n", $$1, $$2}'
16+
17+
init: ## Setup environment (copy template.env to .env)
18+
@if [ ! -f .env ]; then \
19+
cp template.env .env; \
20+
echo "$(GREEN)Created .env file. Please edit it with your settings.$(NC)"; \
21+
else \
22+
echo "$(GREEN).env file already exists.$(NC)"; \
23+
fi
24+
25+
build: ## Build the Docker image
26+
@echo "Building Docker image..."
27+
@if [ -z "$(NGROK_AUTHTOKEN)" ]; then \
28+
echo "$(RED)Error: NGROK_AUTHTOKEN is not set in .env file$(NC)"; \
29+
exit 1; \
30+
fi
31+
docker build -t codequery_core --build-arg NGROK_AUTHTOKEN=$(NGROK_AUTHTOKEN) .
32+
@echo "$(GREEN)Build completed.$(NC)"
33+
34+
run: ## Run the Core container
35+
@echo "Starting Core container..."
36+
@if lsof -i :5001 >/dev/null 2>&1; then \
437
kill -9 $$(lsof -t -i :5001); \
538
echo "Released port 5001"; \
639
fi
7-
# Run the container
8-
docker run --rm -it -p 5001:5001 -p 4040:4040 --name codequery_core -v "$(shell pwd):/app" --env-file .env codequery_core
40+
docker run --rm -d -p 5001:5001 -p 4040:4040 --name codequery_core -v "$(shell pwd):/app" --env-file .env codequery_core
41+
@echo "$(GREEN)Container started. Use 'make logs' to view logs.$(NC)"
942

10-
logs:
43+
stop: ## Stop the Core container
44+
@echo "Stopping Core container..."
45+
@docker stop codequery_core 2>/dev/null || true
46+
@docker rm codequery_core 2>/dev/null || true
47+
@echo "$(GREEN)Container stopped and removed.$(NC)"
48+
49+
logs: ## View container logs
1150
docker logs -f codequery_core
1251

13-
build:
14-
docker build -t codequery_core --build-arg NGROK_AUTHTOKEN=$(NGROK_AUTHTOKEN) .
52+
test: ## Run tests
53+
docker run --rm codequery_core pytest core/tests

0 commit comments

Comments
 (0)