-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
57 lines (42 loc) · 1.19 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
TARGETS = jenkins nginx
TAG_jenkins = my/jenkins
TAG_nginx = my/nginx
ifeq ($(shell uname -s), Linux)
XARGS_ARGS = --no-run-if-empty
else
XARGS_ARGS =
endif
.PHONY: default
default: build
.PHONY: build
build: $(TARGETS:=.build)
.PHONY: $(TARGETS:=.build)
$(TARGETS:=.build): %.build: $*
-docker build -t $(TAG_$*) $*
.PHONY: deploy
deploy: $(STACK:=.deploy)
.PHONY: compose
compose: build
-docker-compose up -d
.PHONY: clean
clean: rm-containers rm-untagged rm-targets
.PHONY: clobber
clobber: clean rm-images
.PHONY: pristine
pristine: clobber rm-volumes
.PHONY: rm-containers
rm-containers:
-docker ps -a -q | xargs $(XARGS_ARGS) docker stop
-docker ps -a -q | xargs $(XARGS_ARGS) docker rm
.PHONY: rm-untagged
rm-untagged:
-docker images | tail -n +2 | awk '$$1 == "<none>" {print $$3}' | xargs $(XARGS_ARGS) docker rmi
.PHONY: rm-targets
rm-targets: rm-containers
-docker rmi -f $(foreach tag,$(TARGETS),$(TAG_$(tag)))
.PHONY: rm-images
rm-images: rm-containers
-docker images | tail -n +2 | awk '{print $$3}' | xargs $(XARGS_ARGS) docker rmi -f
.PHONY: rm-volumes
rm-volumes: rm-containers
-docker volume ls | tail -n +2 | awk '{print $$2}' | xargs $(XARGS_ARGS) docker volume rm -f