This repository has been archived by the owner on Sep 22, 2023. It is now read-only.
forked from dapr/quickstarts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
61 lines (50 loc) · 1.81 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
DOCKER_IMAGE_PREFIX ?=hello-k8s-
APPS ?=node python
SAMPLE_REGISTRY ?=docker.io/dapriosamples
REL_VERSION ?=edge
# Add latest tag if LATEST_RELEASE is true
LATEST_RELEASE ?=
# Docker image build and push setting
DOCKER:=docker
DOCKERFILE:=Dockerfile
.PHONY: build
SAMPLE_APPS:=$(foreach ITEM,$(APPS),$(DOCKER_IMAGE_PREFIX)$(ITEM))
build: copy $(SAMPLE_APPS)
# copy app files from 1.hello-world
copy:
mkdir -p python/.dockerfiles
mkdir -p node/.dockerfiles
cp ../1.hello-world/app.py python/.dockerfiles/
cp ../1.hello-world/app.js node/.dockerfiles/
cp ../1.hello-world/package.json node/.dockerfiles/
cp ../1.hello-world/package-lock.json node/.dockerfiles/
# Generate docker image build targets
# Params:
# $(1): app name
# $(2): tag name
define genDockerImageBuild
.PHONY: $(DOCKER_IMAGE_PREFIX)$(1)
$(DOCKER_IMAGE_PREFIX)$(1):
$(DOCKER) build -f $(1)/$(DOCKERFILE) $(1)/. -t $(SAMPLE_REGISTRY)/$(DOCKER_IMAGE_PREFIX)$(1):$(2)
endef
# Generate docker image build targets
$(foreach ITEM,$(APPS),$(eval $(call genDockerImageBuild,$(ITEM),$(REL_VERSION))))
# push docker image to the registry
.PHONY: push
PUSH_SAMPLE_APPS:=$(foreach ITEM,$(APPS),push-$(DOCKER_IMAGE_PREFIX)$(ITEM))
push: $(PUSH_SAMPLE_APPS)
# Generate docker image push targets
# Params:
# $(1): app name
# $(2): tag name
define genDockerImagePush
.PHONY: push-$(DOCKER_IMAGE_PREFIX)$(1)
push-$(DOCKER_IMAGE_PREFIX)$(1):
$(DOCKER) push $(SAMPLE_REGISTRY)/$(DOCKER_IMAGE_PREFIX)$(1):$(2)
ifeq ($(LATEST_RELEASE),true)
$(DOCKER) tag $(SAMPLE_REGISTRY)/$(DOCKER_IMAGE_PREFIX)$(1):$(2) $(SAMPLE_REGISTRY)/$(DOCKER_IMAGE_PREFIX)$(1):latest
$(DOCKER) push $(SAMPLE_REGISTRY)/$(DOCKER_IMAGE_PREFIX)$(1):latest
endif
endef
# Generate docker image push targets
$(foreach ITEM,$(APPS),$(eval $(call genDockerImagePush,$(ITEM),$(REL_VERSION))))