|
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 \ |
4 | 37 | kill -9 $$(lsof -t -i :5001); \
|
5 | 38 | echo "Released port 5001"; \
|
6 | 39 | 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)" |
9 | 42 |
|
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 |
11 | 50 | docker logs -f codequery_core
|
12 | 51 |
|
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