cmmc-platform/Makefile

54 lines
1.7 KiB
Makefile

# 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 = podman-compose -f dev-compose.yaml
#
# ----------------------------------------------------------
# Helpers
# ----------------------------------------------------------
create-proxy-net:
@podman network exists nginx-proxy || podman 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
podman 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
logs: ## Tail logs
$(compose) logs -f
test: ## Run pytest
PYTHONPATH=. pytest -q
.PHONY: build up down logs test create-proxy-net check-idp