-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
68 lines (53 loc) · 1.77 KB
/
Makefile
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
64
65
66
67
68
SHELL=/bin/bash -o pipefail
REGISTRY ?= ghcr.io/kubedb
BIN ?= mysql-init
IMAGE := $(REGISTRY)/$(BIN)
TAG ?= $(shell git describe --exact-match --abbrev=0 2>/dev/null || echo "")
DOCKER_PLATFORMS := linux/amd64 linux/arm64
PLATFORM ?= linux/$(subst x86_64,amd64,$(subst aarch64,arm64,$(shell uname -m)))
VERSION = $(TAG)_$(subst /,_,$(PLATFORM))
container-%:
@$(MAKE) container \
--no-print-directory \
PLATFORM=$(subst _,/,$*)
push-%:
@$(MAKE) push \
--no-print-directory \
PLATFORM=$(subst _,/,$*)
all-container: $(addprefix container-, $(subst /,_,$(DOCKER_PLATFORMS)))
all-push: $(addprefix push-, $(subst /,_,$(DOCKER_PLATFORMS)))
.PHONY: container
container:
@echo "container: $(IMAGE):$(VERSION)"
@docker buildx build --platform $(PLATFORM) --load --pull -t $(IMAGE):$(VERSION) -f Dockerfile .
@echo
push: container
@docker push $(IMAGE):$(VERSION)
@echo "pushed: $(IMAGE):$(VERSION)"
@echo
.PHONY: docker-manifest
docker-manifest:
docker manifest create -a $(IMAGE):$(TAG) $(foreach PLATFORM,$(DOCKER_PLATFORMS),$(IMAGE):$(TAG)_$(subst /,_,$(PLATFORM)))
docker manifest push $(IMAGE):$(TAG)
.PHONY: release
release:
@$(MAKE) all-push docker-manifest --no-print-directory
.PHONY: version
version:
@echo version=$(VERSION)
.PHONY: fmt
fmt:
@find . -path ./vendor -prune -o -name '*.sh' -exec shfmt -l -w -ci -i 4 {} \;
.PHONY: verify
verify: fmt
@if !(git diff --exit-code HEAD); then \
echo "files are out of date, run make fmt"; exit 1; \
fi
.PHONY: ci
ci: verify
# make and load docker image to kind cluster
.PHONY: push-to-kind
push-to-kind: container
@echo "Loading docker image into kind cluster...."
@kind load docker-image $(IMAGE):$(VERSION)
@echo "Image has been pushed successfully into kind cluster."