github.com/freiheit-com/kuberpult@v1.24.2-0.20240328135542-315d5630abe6/services/cd-service/Makefile (about) 1 # This file is part of kuberpult. 2 3 # Kuberpult is free software: you can redistribute it and/or modify 4 # it under the terms of the Expat(MIT) License as published by 5 # the Free Software Foundation. 6 7 # Kuberpult is distributed in the hope that it will be useful, 8 # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 # MIT License for more details. 11 12 # You should have received a copy of the MIT License 13 # along with kuberpult. If not, see <https://directory.fsf.org/wiki/License:Expat>. 14 15 # Copyright 2023 freiheit.com 16 17 # NOTE: this will be replaced with the etf-golang makefile 18 19 include ../../Makefile.variables 20 21 MAKEFLAGS += --no-builtin-rules 22 23 export CGO_ENABLED=1 24 IMAGE_REGISTRY?=ghcr.io/freiheit-com/kuberpult 25 IMAGENAME?=$(IMAGE_REGISTRY)/kuberpult-cd-service:$(VERSION) 26 ARTIFACT_REGISTRY_IMAGE_NAME=europe-west3-docker.pkg.dev/fdc-public-docker-registry/kuberpult/kuberpult-cd-service:${VERSION} 27 28 export KUBERPULT_DEX_MOCK=false 29 export KUBERPULT_DEX_ENABLED=false 30 31 ifeq ($(WITH_DOCKER),) 32 COMPILE_WITH_DOCKER := false 33 else 34 COMPILE_WITH_DOCKER := true 35 endif 36 37 GO := go 38 39 GO_FILES := $(shell find . -type f -name '*.go') 40 PKG_GO_FILES := $(shell find ../../pkg/ -type f -name '*.go') 41 ALL_GO_FILES := $(GO_FILES) $(PKG_GO_FILES) 42 43 ifeq ($(patsubst %$(VERSION),,$(IMAGENAME)),) 44 else 45 $(error "$(IMAGENAME) doesn't end with $(VERSION). Please set the correct version.") 46 endif 47 48 SERVICE_NAME := $(shell basename $$PWD) 49 EARTHLY := earthly 50 51 image-name: 52 @echo "$(IMAGENAME)" 53 54 version: 55 @echo "$(VERSION)" 56 57 proto: 58 make -C../../pkg/api all 59 60 bin/: 61 mkdir -p bin 62 63 build: bin/main 64 65 build-pr: 66 echo "build on pull request" 67 $(EARTHLY) --push +build-pr --registry=$(IMAGE_REGISTRY) --tag=$(VERSION) --mirror=$(ARTIFACT_REGISTRY_MIRROR) 68 69 build-main: 70 echo "build on main" 71 $(EARTHLY) --push +build-main --registry=$(IMAGE_REGISTRY) --tag=$(VERSION) --mirror=$(ARTIFACT_REGISTRY_MIRROR) 72 73 .PHONY: cleanup-pr 74 cleanup-pr: 75 echo "Nothing to clean" 76 77 .PHONY: cleanup-main 78 cleanup-main: 79 echo "Nothing to clean" 80 81 bin/main: bin/ $(ALL_GO_FILES) | proto 82 @echo "building without docker, just plain go" 83 $(GO) build -o bin/main ./cmd/server/ 84 85 clean: 86 rm -rf pkg/api/api.gen.go 87 rm -rf bin 88 docker rmi $(IMAGENAME) || true 89 90 .PHONY: test-dependancies 91 test-dependancies: 92 make -C ../../pkg test 93 make -C ../../pkg/api test 94 95 test: 96 $(EARTHLY) +unit-test "--GO_TEST_ARGS=$(GO_TEST_ARGS)" 97 98 docker: 99 $(EARTHLY) +docker --registry=$(IMAGE_REGISTRY) --tag=$(VERSION) 100 101 all: test docker 102 103 .PHONY: publish 104 publish: release 105 106 .PHONY: all release test docker clean 107 108 .PHONY: get-builder-image 109 get-builder-image: 110 @echo "$(KUBERPULT_BUILDER)" 111 112 kind-load: docker 113 kind load docker-image "$(IMAGENAME)" 114 115 patch-kind: kind-load 116 kubectl set image deployment/kuberpult-cd-service service=$(IMAGENAME)