IMAGE ?= registry.tanshu.com/menu-admin
PLATFORMS ?= linux/amd64,linux/arm64

.PHONY: build-production build-check build-check-local

# Mirrors the other apps on this machine: a podman manifest build, so one tag
# carries both architectures, pushed to the private registry.
build-production: ## Build and push the production image. Usage: make build-production TAG=2026-09-22
	@test -n "$(TAG)" || { echo "Usage: make build-production TAG=2026-09-22" >&2; exit 1; }
	@echo "Building image..."
	@podman manifest rm $(IMAGE):latest 2>/dev/null || true
	@podman build --platform $(PLATFORMS) --manifest $(IMAGE):latest --pull .
	@echo "Pushing manifests..."
	@podman manifest push --all $(IMAGE):latest docker://$(IMAGE):latest
	@podman manifest push --all $(IMAGE):latest docker://$(IMAGE):$(TAG)

build-check: ## Multi-arch build without pushing, to prove both platforms build
	@podman manifest rm menu-admin:check 2>/dev/null || true
	@podman build --platform $(PLATFORMS) --manifest menu-admin:check --pull .

build-check-local: ## Single-arch build without pushing: the quick local check
	@podman manifest rm menu-admin:check 2>/dev/null || true
	@podman build --platform linux/amd64 --manifest menu-admin:check .
