# Root Makefile for CMMC-Platform local dev ############################################################ # Load .env into Make's environment (must be first!) ############################################################ ifneq (,$(wildcard .env)) include .env export $(shell sed -E 's/#.*//' .env | cut -d= -f1) endif # ───────────── rest of your Makefile below ───────────── compose = docker compose -f dev-compose.yaml # # ---------------------------------------------------------- # Helpers # ---------------------------------------------------------- create-proxy-net: @docker network inspect nginx-proxy >/dev/null 2>&1 || docker network create nginx-proxy # probe external Keycloak once and cache the flag check-idp: @echo "🔍 Probing $(KEYCLOAK_URL) for existing Keycloak..." @if curl -skL --max-time 5 "$${KEYCLOAK_URL:-http://keycloak.local:8080}/realms/master" >/dev/null ; then \ echo "🥳 External Keycloak detected!"; echo 1 >.idp_flag ; \ else \ echo "🛠 No external Keycloak found."; echo 0 >.idp_flag ; \ fi # ---------------------------------------------------------- # Lifecycle targets # ---------------------------------------------------------- build: ## Build FastAPI image docker build -t cmmc-fastapi:latest -f .container-images/fastapi.Dockerfile . up: create-proxy-net check-idp ## Start stack (auto-starts Keycloak only if needed) @if [ "`cat .idp_flag`" = "1" ]; then \ $(compose) up -d ; \ else \ $(compose) --profile idp up -d ; \ fi down: ## Stop stack $(compose) down rebuild: down build up logs: ## Tail logs $(compose) logs -f test: ## Run pytest PYTHONPATH=. pytest -q ps: $(compose) ps .PHONY: build up down logs test create-proxy-net check-idp ps rebuild