-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathMakefile
More file actions
131 lines (111 loc) Β· 4.8 KB
/
Makefile
File metadata and controls
131 lines (111 loc) Β· 4.8 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
PROJECT_ROOT := $(shell pwd)
.PHONY: install run stop stop-dev stop-prod infra api frontend celery clean dev prod check-env build-dev build-prod open-browser
ENV_DIRS := . spectragraph-api spectragraph-core spectragraph-app
open-browser:
@echo "β³ Waiting for frontend to be ready..."
@bash -c 'until curl -s http://localhost:5173 > /dev/null 2>&1; do sleep 1; done'
@echo "π Opening browser..."
@open http://localhost:5173 2>/dev/null || xdg-open http://localhost:5173 2>/dev/null || echo "β
SpectraGraph ready at http://localhost:5173"
check-docker:
@echo "π³ Checking Docker status..."
@docker ps > /dev/null 2>&1 || \
(echo "\nβ Error: Docker is not running!\n" && \
echo "Please start Docker and try again:" && \
echo " β’ Docker Desktop: Open the application" && \
echo " β’ Linux: sudo systemctl start docker\n" && \
exit 1)
@echo "β Docker is running\n"
dev: check-docker
@echo "π Starting SpectraGraph in DEVELOPMENT mode..."
$(MAKE) check-env
docker compose -f docker-compose.dev.yml up --build -d
$(MAKE) open-browser
docker compose -f docker-compose.dev.yml logs -f
prod:
@echo "π Starting SpectraGraph in PRODUCTION mode..."
$(MAKE) check-env
docker compose -f docker-compose.prod.yml up --build -d
$(MAKE) open-browser
build-dev:
@echo "π¨ Building development images..."
docker compose -f docker-compose.dev.yml build
build-prod:
@echo "π¨ Building production images..."
docker compose -f docker-compose.prod.yml build
check-env:
@echo "π Checking .env files..."
@for dir in $(ENV_DIRS); do \
env_file="$$dir/.env"; \
env_example="$(PROJECT_ROOT)/.env.example"; \
if [ -f "$$env_file" ]; then \
echo "β
Using existing .env in $$dir"; \
else \
echo "β οΈ .env missing in $$dir, copying from .env.example"; \
cp "$$env_example" "$$env_file"; \
fi; \
done
install:
@echo "π Installing SpectraGraph project modules..."
@if ! command -v poetry >/dev/null 2>&1; then \
echo "β οΈ Poetry is not installed. Please install it:"; \
echo "pipx install poetry"; \
echo "or"; \
echo "curl -sSL https://install.python-poetry.org | python3 -"; \
exit 1; \
fi
poetry config virtualenvs.in-project true --local
docker compose up -d postgres redis neo4j
poetry install
cd $(PROJECT_ROOT)/spectragraph-core && poetry install
cd $(PROJECT_ROOT)/spectragraph-transforms && poetry install
cd $(PROJECT_ROOT)/spectragraph-api && poetry install && poetry run alembic upgrade head
@echo "β
All modules installed successfully!"
infra:
docker compose up -d
api:
cd $(PROJECT_ROOT)/spectragraph-api && poetry run uvicorn app.main:app --host 0.0.0.0 --port 5001 --reload
frontend:
@echo "π Starting frontend and opening browser..."
@docker compose up -d spectragraph-app
@bash -c 'until curl -s http://localhost:5173 > /dev/null 2>&1; do sleep 1; done; open http://localhost:5173 2>/dev/null || xdg-open http://localhost:5173 2>/dev/null || echo "β
SpectraGraph frontend ready at http://localhost:5173"'
frontend_prod:
cd $(PROJECT_ROOT)/spectragraph-app && npm run build
celery:
cd $(PROJECT_ROOT)/spectragraph-core && poetry run celery -A spectragraph_core.core.celery worker --loglevel=info --pool=solo
run:
@echo "π Starting all services..."
docker compose up -d
@echo "β³ Waiting for frontend to be ready..."
@bash -c 'until curl -s http://localhost:5173 > /dev/null 2>&1; do sleep 1; done'
@echo "π Opening browser..."
@open http://localhost:5173 2>/dev/null || xdg-open http://localhost:5173 2>/dev/null || echo "β
All services ready! SpectraGraph at http://localhost:5173"
$(MAKE) -j2 api celery
stop:
@echo "π Stopping all services..."
-docker compose -f docker-compose.dev.yml down
-docker compose -f docker-compose.prod.yml down
-docker compose down
stop-dev:
@echo "π Stopping development services..."
docker compose -f docker-compose.dev.yml down
stop-prod:
@echo "π Stopping production services..."
docker compose -f docker-compose.prod.yml down
clean:
@echo "β οΈ WARNING: This will remove ALL Docker containers, images, volumes, and virtual environments."
@echo "β οΈ ALL DATA in databases and volumes will be permanently deleted!"
@echo ""
@read -p "Are you sure you want to continue? [y/N]: " confirm; \
if [ "$$confirm" != "y" ] && [ "$$confirm" != "Y" ]; then \
echo "β Cleanup cancelled."; \
exit 1; \
fi
@echo "π§Ή Removing containers, images, volumes and venvs..."
-docker compose -f docker-compose.dev.yml down -v --rmi all --remove-orphans
-docker compose -f docker-compose.prod.yml down -v --rmi all --remove-orphans
-docker compose down -v --rmi all --remove-orphans
rm -rf $(PROJECT_ROOT)/spectragraph-app/node_modules
rm -rf $(PROJECT_ROOT)/spectragraph-core/.venv
rm -rf $(PROJECT_ROOT)/spectragraph-transforms/.venv
rm -rf $(PROJECT_ROOT)/spectragraph-api/.venv
@echo "β
Cleanup complete!"