1
1
SHELL =/bin/bash -o pipefail
2
2
3
- REGISTRY ?= kubedb
4
- BIN : = mysql-init
5
- IMAGE := $(REGISTRY ) /$(BIN )
6
- TAG : = $(shell git describe --exact-match --abbrev=0 2>/dev/null || echo "")
3
+ REGISTRY ?= kubedb
4
+ BIN ? = mysql-init
5
+ IMAGE := $(REGISTRY ) /$(BIN )
6
+ TAG ? = $(shell git describe --exact-match --abbrev=0 2>/dev/null || echo "")
7
7
8
- .PHONY : push
9
- push : container
10
- docker push $(IMAGE ) :$(TAG )
8
+ DOCKER_PLATFORMS := linux/amd64 linux/arm64
9
+ PLATFORM ?= linux/$(subst x86_64,amd64,$(subst aarch64,arm64,$(shell uname -m) ) )
10
+ VERSION = $(TAG ) _$(subst /,_,$(PLATFORM ) )
11
+
12
+ container-% :
13
+ @$(MAKE ) container \
14
+ --no-print-directory \
15
+ PLATFORM=$(subst _,/,$* )
16
+
17
+ push-% :
18
+ @$(MAKE ) push \
19
+ --no-print-directory \
20
+ PLATFORM=$(subst _,/,$* )
21
+
22
+ all-container : $(addprefix container-, $(subst /,_,$(DOCKER_PLATFORMS ) ) )
23
+
24
+ all-push : $(addprefix push-, $(subst /,_,$(DOCKER_PLATFORMS ) ) )
11
25
12
26
.PHONY : container
13
27
container :
14
- wget -qO tini https://github.com/kubedb/tini/releases/download/v0.20.0/tini-static
15
- chmod +x tini
16
- chmod +x init-script/run.sh
17
- find $$(pwd ) /scripts -type f -exec chmod +x {} \;
18
- docker build --pull -t $(IMAGE ) :$(TAG ) .
19
- rm tini
28
+ @echo " container: $( IMAGE) :$( VERSION) "
29
+ @docker buildx build --platform $(PLATFORM ) --load --pull -t $(IMAGE ) :$(VERSION ) -f Dockerfile .
30
+ @echo
31
+
32
+ push : container
33
+ @docker push $(IMAGE ) :$(VERSION )
34
+ @echo " pushed: $( IMAGE) :$( VERSION) "
35
+ @echo
36
+
37
+ .PHONY : docker-manifest
38
+ docker-manifest :
39
+ docker manifest create -a $(IMAGE ) :$(TAG ) $(foreach PLATFORM,$(DOCKER_PLATFORMS ) ,$(IMAGE ) :$(TAG ) _$(subst /,_,$(PLATFORM ) ) )
40
+ docker manifest push $(IMAGE ) :$(TAG )
41
+
42
+ .PHONY : release
43
+ release :
44
+ @$(MAKE ) all-push docker-manifest --no-print-directory
20
45
21
46
.PHONY : version
22
47
version :
23
- @echo ::set-output name=version::$(TAG )
48
+ @echo ::set-output name=version::$(VERSION )
24
49
25
50
.PHONY : fmt
26
51
fmt :
@@ -39,5 +64,5 @@ ci: verify
39
64
.PHONY : push-to-kind
40
65
push-to-kind : container
41
66
@echo " Loading docker image into kind cluster...."
42
- @kind load docker-image $(IMAGE ) :$(TAG )
43
- @echo " Image has been pushed successfully into kind cluster."
67
+ @kind load docker-image $(IMAGE ) :$(VERSION )
68
+ @echo " Image has been pushed successfully into kind cluster."
0 commit comments