# Variables
IMAGE_NAME = registry.espin.casa/cml04-falcon-ui
CONTAINER_NAME = cml04-falcon-ui

# Check if Docker or Podman is available
DOCKER := $(shell command -v docker 2> /dev/null)
PODMAN := $(shell command -v podman 2> /dev/null)

# Determine which command to use based on availability
ifdef DOCKER
	DOCKER_CMD := docker
else ifdef PODMAN
	DOCKER_CMD := podman
else
$(error "Neither Docker nor Podman is installed on this system.")
endif

# Build the Docker image
build:
	$(DOCKER_CMD) build -t $(IMAGE_NAME) -f docker/Dockerfile .

# Run the container
run:
	@templ generate
	@$(DOCKER_CMD) run $(IMAGE_NAME)

# Stop and remove the container
stop:
	$(DOCKER_CMD) stop $(CONTAINER_NAME)
	$(DOCKER_CMD) rm $(CONTAINER_NAME)

# Remove the Docker image
clean:
	$(DOCKER_CMD) rmi $(IMAGE_NAME)