|
1 | 1 | PROJECT_ROOT := $(shell pwd) |
2 | 2 |
|
3 | | -.PHONY: install run stop stop-dev stop-prod infra api frontend celery clean dev prod check-env build-dev build-prod open-browser test |
4 | | -ENV_DIRS := . flowsint-api flowsint-core flowsint-app |
5 | | - |
6 | | -open-browser: |
7 | | - @echo "⏳ Waiting for frontend to be ready..." |
8 | | - @bash -c 'until curl -s http://localhost:5173 > /dev/null 2>&1; do sleep 1; done' |
9 | | - @echo "🌐 Opening browser..." |
10 | | - @open http://localhost:5173 2>/dev/null || xdg-open http://localhost:5173 2>/dev/null || echo "✅ Flowsint ready at http://localhost:5173" |
| 3 | +export DOCKER_BUILDKIT=0 |
| 4 | +export COMPOSE_PARALLEL_LIMIT=1 |
11 | 5 |
|
12 | | -dev: |
13 | | - @echo "🐙 Starting Flowsint in DEVELOPMENT mode..." |
14 | | - $(MAKE) check-env |
15 | | - docker compose -f docker-compose.dev.yml up --build -d |
16 | | - $(MAKE) open-browser |
17 | | - docker compose -f docker-compose.dev.yml logs -f |
18 | | - |
19 | | -prod: |
20 | | - @echo "🐙 Starting Flowsint in PRODUCTION mode..." |
21 | | - $(MAKE) check-env |
22 | | - docker compose -f docker-compose.prod.yml up --build -d |
23 | | - $(MAKE) open-browser |
| 6 | +COMPOSE_DEV := docker compose -f docker-compose.dev.yml |
| 7 | +COMPOSE_PROD := docker compose -f docker-compose.prod.yml |
24 | 8 |
|
25 | | -build-dev: |
26 | | - @echo "🔨 Building development images..." |
27 | | - docker compose -f docker-compose.dev.yml build |
| 9 | +.PHONY: \ |
| 10 | + dev prod \ |
| 11 | + build-dev build-prod \ |
| 12 | + up-dev up-prod down \ |
| 13 | + infra-dev infra-prod infra-stop-dev infra-stop-prod \ |
| 14 | + migrate-dev migrate-prod \ |
| 15 | + api frontend celery \ |
| 16 | + test install clean check-env open-browser |
28 | 17 |
|
29 | | -build-prod: |
30 | | - @echo "🔨 Building production images..." |
31 | | - docker compose -f docker-compose.prod.yml build |
| 18 | +ENV_DIRS := . flowsint-api flowsint-core flowsint-app |
32 | 19 |
|
33 | 20 | check-env: |
34 | | - @echo "🔎 Checking .env files..." |
| 21 | + @echo "Checking .env files..." |
35 | 22 | @for dir in $(ENV_DIRS); do \ |
36 | 23 | env_file="$$dir/.env"; \ |
37 | 24 | env_example="$(PROJECT_ROOT)/.env.example"; \ |
38 | | - if [ -f "$$env_file" ]; then \ |
39 | | - echo "✅ Using existing .env in $$dir"; \ |
40 | | - else \ |
41 | | - echo "⚠️ .env missing in $$dir, copying from .env.example"; \ |
| 25 | + if [ ! -f "$$env_file" ]; then \ |
42 | 26 | cp "$$env_example" "$$env_file"; \ |
| 27 | + echo "Created $$env_file"; \ |
43 | 28 | fi; \ |
44 | 29 | done |
45 | 30 |
|
46 | | -test: |
47 | | - @echo "🔎 Running tests..." |
48 | | - cd $(PROJECT_ROOT)/flowsint-types && poetry run pytest |
49 | | - cd $(PROJECT_ROOT)/flowsint-core && poetry run pytest |
50 | | - cd $(PROJECT_ROOT)/flowsint-enrichers && poetry run pytest |
| 31 | +open-browser: |
| 32 | + @echo "Waiting for frontend..." |
| 33 | + @bash -c 'until curl -s http://localhost:5173 > /dev/null 2>&1; do sleep 1; done' |
| 34 | + @open http://localhost:5173 2>/dev/null || \ |
| 35 | + xdg-open http://localhost:5173 2>/dev/null || \ |
| 36 | + echo "Frontend ready at http://localhost:5173" |
51 | 37 |
|
52 | | -install: |
53 | | - @echo "🐙 Installing Flowsint project modules..." |
54 | | - @if ! command -v poetry >/dev/null 2>&1; then \ |
55 | | - echo "⚠️ Poetry is not installed. Please install it:"; \ |
56 | | - echo "pipx install poetry"; \ |
57 | | - echo "or"; \ |
58 | | - echo "curl -sSL https://install.python-poetry.org | python3 -"; \ |
59 | | - exit 1; \ |
| 38 | +build-dev: |
| 39 | + @echo "Building DEV images..." |
| 40 | + $(COMPOSE_DEV) build |
| 41 | + |
| 42 | +build-prod: |
| 43 | + @echo "Building PROD images..." |
| 44 | + $(COMPOSE_PROD) build |
| 45 | + |
| 46 | +infra-dev: |
| 47 | + @echo "Starting DEV infra (postgres / redis / neo4j)..." |
| 48 | + $(COMPOSE_DEV) up -d postgres redis neo4j |
| 49 | + |
| 50 | +infra-prod: |
| 51 | + @echo "Starting PROD infra (postgres / redis / neo4j)..." |
| 52 | + $(COMPOSE_PROD) up -d postgres redis neo4j |
| 53 | + |
| 54 | +infra-stop-dev: |
| 55 | + @echo "Stopping DEV infra..." |
| 56 | + $(COMPOSE_DEV) stop postgres redis neo4j |
| 57 | + |
| 58 | +infra-stop-prod: |
| 59 | + @echo "Stopping PROD infra..." |
| 60 | + $(COMPOSE_PROD) stop postgres redis neo4j |
| 61 | + |
| 62 | +migrate-dev: |
| 63 | + @echo "Running DEV migrations..." |
| 64 | + @if ! $(COMPOSE_DEV) ps -q neo4j | grep -q .; then \ |
| 65 | + echo "Neo4j not running → starting DEV infra"; \ |
| 66 | + $(COMPOSE_DEV) up -d --wait neo4j; \ |
60 | 67 | fi |
61 | | - poetry config virtualenvs.in-project true --local |
62 | | - docker compose up -d postgres redis neo4j |
63 | | - poetry install |
64 | | - cd $(PROJECT_ROOT)/flowsint-core && poetry install |
65 | | - cd $(PROJECT_ROOT)/flowsint-enrichers && poetry install |
66 | | - cd $(PROJECT_ROOT)/flowsint-api && poetry install && poetry run alembic upgrade head |
67 | | - @echo "✅ All modules installed successfully!" |
| 68 | + yarn migrate |
| 69 | + |
| 70 | +migrate-prod: |
| 71 | + @echo "⚠️ Running PROD migrations" |
| 72 | + @echo "This will ALTER production data." |
| 73 | + @read -p "Type 'prod' to continue: " confirm; \ |
| 74 | + if [ "$$confirm" != "prod" ]; then \ |
| 75 | + echo "Aborted."; exit 1; \ |
| 76 | + fi |
| 77 | + yarn migrate |
68 | 78 |
|
69 | | -infra: |
70 | | - docker compose up -d |
| 79 | +dev: |
| 80 | + @echo "Starting DEV environment..." |
| 81 | + $(MAKE) check-env |
| 82 | + $(MAKE) infra-dev |
| 83 | + $(MAKE) migrate-dev |
| 84 | + $(MAKE) build-dev |
| 85 | + $(MAKE) up-dev |
| 86 | + $(MAKE) open-browser |
| 87 | + $(COMPOSE_DEV) logs -f |
71 | 88 |
|
72 | | -api: |
73 | | - cd $(PROJECT_ROOT)/flowsint-api && poetry run uvicorn app.main:app --host 0.0.0.0 --port 5001 --reload |
| 89 | +prod: |
| 90 | + @echo "Starting PROD environment..." |
| 91 | + $(MAKE) check-env |
| 92 | + $(MAKE) build-prod |
| 93 | + $(MAKE) up-prod |
74 | 94 |
|
75 | | -frontend: |
76 | | - @echo "🐙 Starting frontend and opening browser..." |
77 | | - @docker compose up -d flowsint-app |
78 | | - @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 "✅ Frontend ready at http://localhost:5173"' |
| 95 | +up-dev: |
| 96 | + $(COMPOSE_DEV) up -d --no-build |
79 | 97 |
|
80 | | -frontend_prod: |
81 | | - cd $(PROJECT_ROOT)/flowsint-app && npm run build |
| 98 | +up-prod: |
| 99 | + $(COMPOSE_PROD) up -d --no-build |
82 | 100 |
|
83 | | -celery: |
84 | | - cd $(PROJECT_ROOT)/flowsint-core && poetry run celery -A flowsint_core.core.celery worker --loglevel=info --pool=threads --concurrency=10 |
| 101 | +down: |
| 102 | + -$(COMPOSE_DEV) down |
| 103 | + -$(COMPOSE_PROD) down |
85 | 104 |
|
86 | | -run: |
87 | | - @echo "🐙 Starting all services..." |
88 | | - docker compose up -d |
89 | | - @echo "⏳ Waiting for frontend to be ready..." |
90 | | - @bash -c 'until curl -s http://localhost:5173 > /dev/null 2>&1; do sleep 1; done' |
91 | | - @echo "🌐 Opening browser..." |
92 | | - @open http://localhost:5173 2>/dev/null || xdg-open http://localhost:5173 2>/dev/null || echo "✅ All services ready! Flowsint at http://localhost:5173" |
93 | | - $(MAKE) -j2 api celery |
| 105 | +api: |
| 106 | + cd $(PROJECT_ROOT)/flowsint-api && \ |
| 107 | + poetry run uvicorn app.main:app --host 0.0.0.0 --port 5001 --reload |
94 | 108 |
|
95 | | -stop: |
96 | | - @echo "🛑 Stopping all services..." |
97 | | - -docker compose -f docker-compose.dev.yml down |
98 | | - -docker compose -f docker-compose.prod.yml down |
99 | | - -docker compose down |
| 109 | +frontend: |
| 110 | + $(COMPOSE_DEV) up -d flowsint-app |
| 111 | + $(MAKE) open-browser |
| 112 | + |
| 113 | +celery: |
| 114 | + cd $(PROJECT_ROOT)/flowsint-core && \ |
| 115 | + poetry run celery -A flowsint_core.core.celery \ |
| 116 | + worker --loglevel=info --pool=threads --concurrency=10 |
100 | 117 |
|
101 | | -stop-dev: |
102 | | - @echo "🛑 Stopping development services..." |
103 | | - docker compose -f docker-compose.dev.yml down |
| 118 | +test: |
| 119 | + cd flowsint-types && poetry run pytest |
| 120 | + cd flowsint-core && poetry run pytest |
| 121 | + cd flowsint-enrichers && poetry run pytest |
104 | 122 |
|
105 | | -stop-prod: |
106 | | - @echo "🛑 Stopping production services..." |
107 | | - docker compose -f docker-compose.prod.yml down |
| 123 | +install: |
| 124 | + poetry config virtualenvs.in-project true --local |
| 125 | + $(MAKE) infra-dev |
| 126 | + poetry install |
| 127 | + cd flowsint-core && poetry install |
| 128 | + cd flowsint-enrichers && poetry install |
| 129 | + cd flowsint-api && poetry install && poetry run alembic upgrade head |
108 | 130 |
|
109 | 131 | clean: |
110 | | - @echo "⚠️ WARNING: This will remove ALL Docker containers, images, volumes, and virtual environments." |
111 | | - @echo "⚠️ ALL DATA in databases and volumes will be permanently deleted!" |
112 | | - @echo "" |
113 | | - @read -p "Are you sure you want to continue? [y/N]: " confirm; \ |
114 | | - if [ "$$confirm" != "y" ] && [ "$$confirm" != "Y" ]; then \ |
115 | | - echo "❌ Cleanup cancelled."; \ |
116 | | - exit 1; \ |
117 | | - fi |
118 | | - @echo "🧹 Removing containers, images, volumes and venvs..." |
119 | | - -docker compose -f docker-compose.dev.yml down -v --rmi all --remove-orphans |
120 | | - -docker compose -f docker-compose.prod.yml down -v --rmi all --remove-orphans |
121 | | - -docker compose down -v --rmi all --remove-orphans |
122 | | - rm -rf $(PROJECT_ROOT)/flowsint-app/node_modules |
123 | | - rm -rf $(PROJECT_ROOT)/flowsint-core/.venv |
124 | | - rm -rf $(PROJECT_ROOT)/flowsint-enrichers/.venv |
125 | | - rm -rf $(PROJECT_ROOT)/flowsint-api/.venv |
126 | | - @echo "✅ Cleanup complete!" |
| 132 | + @echo "This will remove ALL Docker data. Continue? [y/N]" |
| 133 | + @read confirm; \ |
| 134 | + if [ "$$confirm" != "y" ]; then exit 1; fi |
| 135 | + -$(COMPOSE_DEV) down -v --rmi all --remove-orphans |
| 136 | + -$(COMPOSE_PROD) down -v --rmi all --remove-orphans |
| 137 | + rm -rf flowsint-app/node_modules |
| 138 | + rm -rf flowsint-core/.venv |
| 139 | + rm -rf flowsint-enrichers/.venv |
| 140 | + rm -rf flowsint-api/.venv |
0 commit comments