# Airport Cyber Resilience Simulator — convenience wrapper around docker compose.
# Usage: make up | make down | make logs | make rebuild | make ps | make health

COMPOSE ?= docker compose
SERVICE ?= airport-cyber-sim
URL     ?= http://localhost:8000

.PHONY: up down logs rebuild ps health restart shell clean

up:            ## Build (if needed) and start in the background
	$(COMPOSE) up --build -d
	@echo "Airport Cyber Resilience Simulator running at $(URL)"

down:          ## Stop and remove containers
	$(COMPOSE) down

logs:          ## Tail service logs
	$(COMPOSE) logs -f $(SERVICE)

rebuild:       ## Force a clean rebuild with no cache, then start
	$(COMPOSE) build --no-cache
	$(COMPOSE) up -d
	@echo "Rebuilt and running at $(URL)"

restart:       ## Restart the service
	$(COMPOSE) restart $(SERVICE)

ps:            ## Show container status
	$(COMPOSE) ps

health:        ## Show the container health state
	@docker inspect --format '{{.State.Health.Status}}' $(SERVICE) 2>/dev/null || echo "container not running"

shell:         ## Open a shell inside the running container
	$(COMPOSE) exec $(SERVICE) /bin/bash

clean:         ## Stop and remove containers, image and build cache
	$(COMPOSE) down --rmi local --remove-orphans
