# Thin alias layer over ./build.sh — provides the conventional `make dev` /
# `make prod` verbs. All real work happens in build.sh; targets here just
# forward. For single-service rebuilds drop to the script directly:
#   ./build.sh dev backend
#   ./build.sh prod worker

# Bare `make` (no target) prints help instead of silently running the first
# target. Mode must be explicit: `make dev`, `make prod`, `make help`, …
.DEFAULT_GOAL := help

.PHONY: help dev prod down clean

help: ## Show available make targets (this list).
	@printf "Available make targets:\n\n"
	@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "  \033[36m%-18s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
	@printf "\nFor build.sh flags + single-service rebuilds, run: \033[36m./build.sh help\033[0m\n"

dev: ## Build & start the dev stack (hot reload, source mounts).
	@./build.sh dev

prod: ## Build & start the prod stack (slim images, gunicorn, nginx-served SPA).
	@./build.sh prod

down: ## Stop & remove containers (volumes preserved). Non-destructive.
	@docker compose down --remove-orphans

# Full reset — stops containers and wipes every named volume:
#   fromspec_postgres_data  app + Keycloak DB
#   fromspec_redis_data     pipeline events / locks / caches
#   fromspec_data           generated project artifacts
# Realm config and migrations re-apply automatically on next start.
clean: ## Stop everything and wipe ALL named volumes (full reset).
	@printf "Wipe all named volumes (DB, project data, redis)? [y/N] " && read ans && [ "$$ans" = "y" ] || exit 1
	@docker compose down -v --remove-orphans
	@echo "✓ Cleaned. Next 'make dev' / 'make prod' will re-pull / regenerate everything."
