generated from clusterpedia-io/sample-storage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
63 lines (50 loc) · 1.85 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
STORAGE_PLUGIN ?= $(shell sed -n '1p' go.mod | awk '{print $$2}' | awk -F'/' '{print $$NF}')
REGISTRY ?= "ghcr.io/clusterpedia-io/clusterpedia"
CLUSTERPEDIA_BUILDER_IMAGE = "ghcr.io/clusterpedia-io/clusterpedia/builder"
CLUSTERPEDIA_VERSIONS = v0.6.0-beta.1 v0.6.0
RELEASE_ARCHS ?= amd64 arm64
BUILDER_IMAGE ?= ""
VERSION = $(shell git describe --tags 2>/dev/null)
ifeq ($(VERSION),)
VERSION = v0.0.0
endif
BUILDER_TAG ?= $(shell echo $(BUILDER_IMAGE)|awk -F ':' '{ print $$2 }')
ifeq ($(BUILDER_TAG),)
BUILDER_TAG = latest
endif
GOARCH ?= $(shell go env GOARCH)
PWD = $(shell pwd)
CLUSTERPEDIA_REPO ?= $(PWD)/clusterpedia
build-plugin:
CLUSTERPEDIA_REPO=$(CLUSTERPEDIA_REPO) \
clusterpedia/hack/builder.sh plugins $(STORAGE_PLUGIN).so
build-components:
OUTPUT_DIR=$(PWD) ON_PLUGINS=true \
$(MAKE) -C clusterpedia all
image-plugin:
ifeq ($(BUILDER_IMAGE), "")
$(error BUILDER_IMAGE is not define)
endif
docker buildx build \
-t $(REGISTRY)/$(STORAGE_PLUGIN)-$(GOARCH):$(VERSION)-$(BUILDER_TAG) \
--platform=linux/$(GOARCH) \
--load \
--build-arg BUILDER_IMAGE=$(BUILDER_IMAGE) \
--build-arg PLUGIN_NAME=$(STORAGE_PLUGIN).so .
push-images: clean-manifests
set -e; \
for version in $(CLUSTERPEDIA_VERSIONS); do \
images=""; \
for arch in $(RELEASE_ARCHS); do \
GOARCH=$$arch BUILDER_IMAGE=$(CLUSTERPEDIA_BUILDER_IMAGE):$$version BUILDER_TAG=$$version $(MAKE) image-plugin; \
image=$(REGISTRY)/$(STORAGE_PLUGIN)-$$arch:$(VERSION)-$$version; \
docker push $$image; \
images="$$images $$image"; \
done; \
docker manifest create $(REGISTRY)/$(STORAGE_PLUGIN):$(VERSION)-$$version $$images; \
docker manifest push $(REGISTRY)/$(STORAGE_PLUGIN):$(VERSION)-$$version; \
done;
clean-manifests:
for version in $(CLUSTERPEDIA_VERSIONS); do \
docker manifest rm $(REGISTRY)/$(STORAGE_PLUGIN):$(VERSION)-$$version 2>/dev/null; \
done; exit 0