feat: more robust Makefile

This commit is contained in:
dextmorgn
2026-01-25 11:39:10 +01:00
parent 2f5443b074
commit 154cc74e80

View File

@@ -1,12 +1,15 @@
# =====================
# Global configuration
# =====================
PROJECT_ROOT := $(shell pwd)
# Disable BuildKit for local stability
export DOCKER_BUILDKIT=0
export COMPOSE_PARALLEL_LIMIT=1
COMPOSE_DEV := docker compose -f docker-compose.dev.yml
COMPOSE_PROD := docker compose -f docker-compose.prod.yml
.PHONY: \
dev prod \
build-dev build-prod \
@@ -20,13 +23,6 @@ ENV_DIRS := . flowsint-api flowsint-core flowsint-app
# Helpers
# =====================
open-browser:
@echo "Waiting for frontend..."
@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"
check-env:
@echo "Checking .env files..."
@for dir in $(ENV_DIRS); do \
@@ -38,32 +34,48 @@ check-env:
fi; \
done
open-browser:
@echo "Waiting for frontend..."
@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"
# =====================
# Build targets
# Build
# =====================
build-dev:
@echo "Building DEV images..."
docker compose -f docker-compose.dev.yml build
$(COMPOSE_DEV) build
build-prod:
@echo "Building PROD images..."
docker compose -f docker-compose.prod.yml build
$(COMPOSE_PROD) build
# =====================
# Up / Down
# Infra
# =====================
up-dev:
docker compose -f docker-compose.dev.yml up -d --no-build
infra:
@echo "Starting infra (postgres / redis / neo4j)..."
$(COMPOSE_DEV) up -d postgres redis neo4j
up-prod:
docker compose -f docker-compose.prod.yml up -d --no-build
infra-stop:
@echo "Stopping infra..."
$(COMPOSE_DEV) stop postgres redis neo4j
down:
-docker compose -f docker-compose.dev.yml down
-docker compose -f docker-compose.prod.yml down
-docker compose down
# =====================
# Migrations
# =====================
migrate:
@echo "Running migrations..."
@if ! $(COMPOSE_DEV) ps -q neo4j | grep -q .; then \
echo "Neo4j not running → starting infra"; \
$(COMPOSE_DEV) up -d --wait neo4j; \
fi
yarn migrate
# =====================
# Main workflows
@@ -72,19 +84,32 @@ down:
dev:
@echo "Starting DEV environment..."
$(MAKE) check-env
$(MAKE) infra
$(MAKE) migrate
$(MAKE) build-dev
$(MAKE) up-dev
$(MAKE) open-browser
docker compose -f docker-compose.dev.yml logs -f
$(COMPOSE_DEV) logs -f
prod:
@echo "Starting PROD environment..."
$(MAKE) check-env
$(MAKE) migrate
$(MAKE) build-prod
$(MAKE) up-prod
$(MAKE) open-browser
# =====================
# Up / Down
# =====================
up-dev:
$(COMPOSE_DEV) up -d --no-build
up-prod:
$(COMPOSE_PROD) up -d --no-build
down:
-$(COMPOSE_DEV) down
-$(COMPOSE_PROD) down
# =====================
# Local commands
@@ -95,7 +120,7 @@ api:
poetry run uvicorn app.main:app --host 0.0.0.0 --port 5001 --reload
frontend:
docker compose up -d flowsint-app
$(COMPOSE_DEV) up -d flowsint-app
$(MAKE) open-browser
celery:
@@ -103,31 +128,18 @@ celery:
poetry run celery -A flowsint_core.core.celery \
worker --loglevel=info --pool=threads --concurrency=10
# =====================
# Infra / DB
# =====================
infra:
docker compose up -d postgres redis neo4j
migrate:
@echo "Running migrations..."
docker compose up -d --wait neo4j
yarn migrate
docker compose stop neo4j
# =====================
# Tests / Install
# =====================
test:
cd $(PROJECT_ROOT)/flowsint-types && poetry run pytest
cd $(PROJECT_ROOT)/flowsint-core && poetry run pytest
cd $(PROJECT_ROOT)/flowsint-enrichers && poetry run pytest
cd flowsint-types && poetry run pytest
cd flowsint-core && poetry run pytest
cd flowsint-enrichers && poetry run pytest
install:
poetry config virtualenvs.in-project true --local
docker compose up -d postgres redis neo4j
$(MAKE) infra
poetry install
cd flowsint-core && poetry install
cd flowsint-enrichers && poetry install
@@ -141,8 +153,8 @@ clean:
@echo "This will remove ALL Docker data. Continue? [y/N]"
@read confirm; \
if [ "$$confirm" != "y" ]; then exit 1; fi
-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
-$(COMPOSE_DEV) down -v --rmi all --remove-orphans
-$(COMPOSE_PROD) down -v --rmi all --remove-orphans
rm -rf flowsint-app/node_modules
rm -rf flowsint-core/.venv
rm -rf flowsint-enrichers/.venv