-
Notifications
You must be signed in to change notification settings - Fork 18
/
Makefile.cleanpushpull
81 lines (66 loc) · 1.93 KB
/
Makefile.cleanpushpull
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
70
71
72
73
74
75
76
77
78
79
80
81
# Copyright (c) 2016-2025 Crave.io Inc. All rights reserved
# This template must only be included by the actual image building makefile
.PHONY: manifest get_image_name clean push pull tag-latest it help
ifdef IMGVER_BASE
#IMGVER:=${IMGVER_BASE}_$(shell uname -m)
manifest:
-${DOCKER} manifest rm ${IMGTAG}:${IMGVER_BASE}
${DOCKER} manifest create \
${IMGTAG}:${IMGVER_BASE} \
$(foreach var,${IMGVER_TARGETS},--amend ${IMGTAG}:${IMGVER_BASE}_$(var))
${DOCKER} manifest push ${IMGTAG}:${IMGVER_BASE}
is_arch_specific:
@echo "YES"
else
manifest:
echo "There is no base image defined. No manifest required."
is_arch_specific:
@echo "NO"
endif
get_image_name:
ifdef IMGVER_BASE
@$(foreach var,${IMGVER_TARGETS},echo "${var} ${IMGTAG}:${IMGVER_BASE}_${var}";)
else
@echo "default $(IMGTAG):$(IMGVER)"
endif
clean:
-${DOCKER} rm $$(${DOCKER} ps -aq)
-${DOCKER} images | \
awk '{ if ($$1 == "$(IMGTAG)" && $$2 == "$(IMGVER)") { print $$1":"$$2 } }' | \
while read line ; do ${DOCKER} rmi $$line ; done
-${DOCKER} images | \
grep '<none>' | \
awk '{ print $$3 }' | \
while read line ; do ${DOCKER} rmi $$line ; done
ifdef IMGVER_BASE
push_%:
${DOCKER} push $(IMGTAG):$(IMGVER_BASE)_$*
push: $(foreach var,$(IMGVER_TARGETS),push_$(var))
else
push:
${DOCKER} push $(IMGTAG):$(IMGVER)
endif
ifdef IMGVER_BASE
pull_%:
${DOCKER} pull $(IMGTAG):$(IMGVER_BASE)_$*
pull: $(foreach var,$(IMGVER_TARGETS),pull_$(var))
else
pull:
${DOCKER} pull $(IMGTAG):$(IMGVER)
endif
tag-latest:
ifdef IMGVER_BASE
${DOCKER} tag $(IMGTAG):$(IMGVER_BASE) $(IMGTAG):latest
else
${DOCKER} tag $(IMGTAG):$(IMGVER) $(IMGTAG):latest
endif
it:
ifdef IMGVER_BASE
${DOCKER} run --rm -it ${DOCKER_RUN_FLAGS} $(IMGTAG):$(IMGVER_BASE) $(DOCKER_RUN_CMD)
else
${DOCKER} run --rm -it ${DOCKER_RUN_FLAGS} $(IMGTAG):$(IMGVER) $(DOCKER_RUN_CMD)
endif
help:
@echo "Usage"
@echo "make [manifest|get_image_name|clean|push|pull|tag-latest|it|help]"
@echo "make build [NOCACHE=y]"