VERSION ?= dev
BUILD_TIME := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
REGISTRY := gitea.dooplex.hu/admin
IMAGE := $(REGISTRY)/felhom-hub

.PHONY: build run docker docker-push clean

build:
	CGO_ENABLED=0 go build -ldflags "-s -w -X main.Version=$(VERSION) -X main.BuildTime=$(BUILD_TIME)" \
		-o bin/felhom-hub ./cmd/hub/

run: build
	./bin/felhom-hub -config configs/hub.yaml.example

docker:
	docker build --build-arg VERSION=$(VERSION) --build-arg BUILD_TIME=$(BUILD_TIME) \
		-t $(IMAGE):$(VERSION) .

docker-push: docker
	docker push $(IMAGE):$(VERSION)
	docker tag $(IMAGE):$(VERSION) $(IMAGE):latest
	docker push $(IMAGE):latest

clean:
	rm -rf bin/
