forked from hmcts/cnp-node-base
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
52 lines (39 loc) · 1.48 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
.DEFAULT_GOAL:= build
.REGISTRY = hmctspublic.azurecr.io
.SANDBOX_REGISTRY = hmctssandbox.azurecr.io
.NAMESPACES = base/node
.REFS = alpine-lts-8►8/alpine \
alpine-lts-10►10/alpine \
alpine-lts-12►12/alpine \
stretch-slim-lts-8►8/stretch-slim \
stretch-slim-lts-10►10/stretch-slim \
stretch-slim-lts-12►12/stretch-slim
define run-docker
docker build \
-t $(.REGISTRY)/$(.NAMESPACES)/$(word 1,$(subst ►, ,$(1))) \
-f $(word 2,$(subst ►, ,$(1)))/Dockerfile \
.
endef
define run-test
@./test-build.sh $(.REGISTRY)/$(.NAMESPACES)/$(word 1,$(subst ►, ,$(1)))
endef
define push-sandbox
docker tag \
$(.REGISTRY)/$(.NAMESPACES)/$(word 1,$(subst ►, ,$(1))) \
$(.SANDBOX_REGISTRY)/$(.NAMESPACES)/$(word 1,$(subst ►, ,$(1)))
docker push $(.SANDBOX_REGISTRY)/$(.NAMESPACES)/$(word 1,$(subst ►, ,$(1)))
endef
help:
@echo ""
@echo " Available commands:"
@echo " -------------------"
@echo ""
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " make \033[36m%-30s\033[0m %s\n", $$1, $$2}'
@echo ""
build: ## Build locally the base images.
$(foreach ref,$(.REFS),$(call run-docker,$(ref)))
test: ## Test basic properties of the images, e.g. user, workdir, default command.
$(foreach tag,$(.REFS),$(call run-test,$(tag)))
sandbox: ## Tag the images and pushes them to hmctssandbox.azurecr.io sandbox ACR (make sure you are logged in).
$(foreach ref,$(.REFS),$(call push-sandbox,$(ref)))
.PHONY: build test sandbox help