This repository has been archived by the owner on Jul 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
69 lines (62 loc) · 1.76 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
69
CR = univer-acr-registry.cn-shenzhen.cr.aliyuncs.com
LOCAL_TAG = dev
PUSH_TAG ?= latest
PUSH_TAG_AS_LATEST ?= true
REPOSITORY = univer-examples
NS ?= univer
CTR = docker
BUILDER ?= univer-examples-builder
PROXY ?=
OSARCH = linux/amd64,linux/arm64/v8
.PHONY: create_builder
# Check if the builder exists and create it if not
create_builder:
@if ! $(CTR) buildx inspect $(BUILDER) > /dev/null 2>&1; then \
$(CTR) buildx create --name $(BUILDER) --use; \
fi
.PHONY: build_image
# docker buildx build image for univer examples
build_image: create_builder
$(CTR) buildx build \
--builder $(BUILDER) \
--platform linux/$(shell docker version -f '{{.Server.Arch}}') \
--file Dockerfile \
-t $(REPOSITORY):$(LOCAL_TAG) \
--load .
.PHONY: push_image
# Build and Push multi-platform Docker images for univer examples
push_image: create_builder
ifeq ($(PUSH_TAG), latest)
$(eval image_tag=-t $(CR)/$(NS)/$(REPOSITORY):latest)
else ifeq ($(PUSH_TAG_AS_LATEST), true)
$(eval image_tag=-t $(CR)/$(NS)/$(REPOSITORY):$(PUSH_TAG) -t $(CR)/$(NS)/$(REPOSITORY):latest)
else
$(eval image_tag=-t $(CR)/$(NS)/$(REPOSITORY):$(PUSH_TAG))
endif
$(CTR) buildx build \
--builder $(BUILDER) \
--platform $(OSARCH) \
--file Dockerfile \
$(image_tag) \
--push .
.PHONY: clean_builder
# Clean up the builder instance
clean_builder:
@docker buildx rm $(BUILDER)
# show help
help:
@echo ''
@echo 'Usage:'
@echo ' make [target]'
@echo ''
@echo 'Targets:'
@awk '/^[a-zA-Z\-\_0-9]+:/ { \
helpMessage = match(lastLine, /^# (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")); \
helpMessage = substr(lastLine, RSTART + 2, RLENGTH); \
printf "\033[36m%-25s\033[0m %s\n", helpCommand,helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)
.DEFAULT_GOAL := help