project_root := justfile_directory()
backend_dir := project_root + "/Backend"
backend_bake := project_root + "/Backend/docker-bake.hcl"
store_dir := project_root + "/Store"
store_bake := project_root + "/Store/docker-bake.hcl"
local_compose := project_root + "/Docker/docker-compose.local.dev.yaml"

mod frontend
mod backend
mod stripe

# Default flow: rebuild the local development images and recreate the stack.
rebuild:
	cd '{{backend_dir}}' && docker buildx bake -f '{{backend_bake}}' dev
	cd '{{store_dir}}' && docker buildx bake -f '{{store_bake}}' dev
	docker compose -f '{{local_compose}}' up -d --remove-orphans --force-recreate

# Build the local development images.
build:
	cd '{{backend_dir}}' && docker buildx bake -f '{{backend_bake}}' dev
	cd '{{store_dir}}' && docker buildx bake -f '{{store_bake}}' dev

# Start the local development stack in the background using the current image.
up:
	docker compose -f '{{local_compose}}' up -d --remove-orphans --force-recreate

# Build first, then start the local development stack in the background.
start: build up

# Stop and remove the local development stack.
down:
	docker compose -f '{{local_compose}}' down --remove-orphans --volumes

# Follow logs for the local development stack.
logs:
	docker compose -f '{{local_compose}}' logs -f

# Restart the local development stack.
restart:
	docker compose -f '{{local_compose}}' restart
