IMAGE_NAME := rats-app
IMAGE_TAG  := latest
K8S_DIR    := k8s

.PHONY: build start stop restart logs status

## Build the Docker image
build:
	docker build -t $(IMAGE_NAME):$(IMAGE_TAG) ./app

## Build image and apply all K8s manifests (Docker Desktop Kubernetes)
start: build
	kubectl apply -k $(K8S_DIR)/

## Delete all K8s resources in the rats namespace
stop:
	kubectl delete -k $(K8S_DIR)/ --ignore-not-found

## Full restart: tear down, rebuild, redeploy
restart: stop start

## Stream app logs
logs:
	kubectl logs -n rats -l app=rats-app -f

## Show pod status in the rats namespace
status:
	kubectl get pods -n rats
