.DEFAULT_GOAL := all

build: clean
	bee pack

run:
	./oc-discovery

clean:
	rm -rf  oc-discovery

docker:
	DOCKER_BUILDKIT=1 docker build --build-arg CONF_NUM=5 -t oc-discovery_1 -f Dockerfile .
	docker tag oc-discovery_1 opencloudregistry/oc-discovery_1:latest
	DOCKER_BUILDKIT=1 docker build --build-arg CONF_NUM=2 -t oc-discovery_2 -f Dockerfile .
	docker tag oc-discovery_2 opencloudregistry/oc-discovery_2:latest
	DOCKER_BUILDKIT=1 docker build --build-arg CONF_NUM=3 -t oc-discovery_3 -f Dockerfile .
	docker tag oc-discovery_3 opencloudregistry/oc-discovery_3:latest
	DOCKER_BUILDKIT=1 docker build --build-arg CONF_NUM=4 -t oc-discovery_4 -f Dockerfile .
	docker tag oc-discovery_4 opencloudregistry/oc-discovery_4:latest
	DOCKER_BUILDKIT=1 docker build --build-arg CONF_NUM=6 -t oc-discovery_6 -f Dockerfile .
	docker tag oc-discovery_6 opencloudregistry/oc-discovery_6:latest

publish-kind:
	kind load docker-image opencloudregistry/oc-discovery:latest --name opencloud

publish-registry:
	docker push opencloudregistry/oc-discovery_1:latest
	docker push opencloudregistry/oc-discovery_2:latest
	docker push opencloudregistry/oc-discovery_3:latest
	docker push opencloudregistry/oc-discovery_4:latest
	docker push opencloudregistry/oc-discovery_6:latest

all: docker publish-kind

ci: docker publish-registry

.PHONY: build run clean docker publish-kind publish-registry