-
Notifications
You must be signed in to change notification settings - Fork 3
/
ci.mk
63 lines (50 loc) · 2.37 KB
/
ci.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Image URL to use all building/pushing image targets
IMG_TAG ?= latest
APP_NAME ?= provider-exoscale
ORG ?= vshn
IMG_REPO ?= ghcr.io
IMG ?= $(IMG_REPO)/$(ORG)/$(APP_NAME):$(IMG_TAG)
DOCKER_CMD ?= docker
# Upbound push config
UPBOUND_CONTAINER_REGISTRY ?= xpkg.upbound.io
UPBOUND_PACKAGE_IMG ?= $(UPBOUND_CONTAINER_REGISTRY)/$(ORG)/$(APP_NAME):$(IMG_TAG)
# For alpine image it is required the following env before building the application
DOCKER_IMAGE_GOOS = linux
DOCKER_IMAGE_GOARCH = amd64
.PHONY: docker-build
docker-build:
env CGO_ENABLED=0 GOOS=$(DOCKER_IMAGE_GOOS) GOARCH=$(DOCKER_IMAGE_GOARCH) \
go build -o ${BIN_FILENAME}
docker build --platform $(DOCKER_IMAGE_GOOS)/$(DOCKER_IMAGE_GOARCH) -t ${IMG} .
.PHONY: docker-build-branchtag
docker-build-branchtag: export IMG_TAG=$(shell git rev-parse --abbrev-ref HEAD | sed 's/\//_/g')
docker-build-branchtag: docker-build ## Build docker image with current branch name
.PHONY: docker-push
docker-push: docker-build ## Push docker image with the manager.
docker push ${IMG}
.PHONY: docker-push-branchtag
docker-push-branchtag: export IMG_TAG=$(shell git rev-parse --abbrev-ref HEAD | sed 's/\//_/g')
docker-push-branchtag: docker-build-branchtag docker-push ## Push docker image with current branch name
.PHONY: package-build
package-build: docker-build
rm -f package/*.xpkg
go run github.com/crossplane/crossplane/cmd/[email protected] xpkg build -f package --verbose --embed-runtime-image=${IMG} -o package/package.xpkg
.PHONY: package-push
package-push: package-build
go run github.com/crossplane/crossplane/cmd/[email protected] xpkg push -f package/package.xpkg ${IMG} --verbose
.PHONY: package-build-branchtag
package-build-branchtag: export IMG_TAG=$(shell git rev-parse --abbrev-ref HEAD | sed 's/\//_/g')
package-build-branchtag: docker-build-branchtag package-build
.PHONY: package-push-package-branchtag
package-push-branchtag: export IMG_TAG=$(shell git rev-parse --abbrev-ref HEAD | sed 's/\//_/g')
package-push-branchtag: package-build-branchtag package-push
.PHONY: docker-build-local
docker-build-local: export IMG_REPO=localhost:5000
docker-build-local:
$(MAKE) docker-build
.PHONY: package-build-local
package-build-local: export IMG_REPO=localhost:5000
package-build-local: docker-build-local package-build
.PHONY: package-push-local
package-push-local: export IMG_REPO=localhost:5000
package-push-local: package-build-local package-push