-
Notifications
You must be signed in to change notification settings - Fork 39
/
Makefile
60 lines (44 loc) · 1.32 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
BOXES := $(notdir $(wildcard docker/*))
PROCESS_CONTROL ?= systemd
SERVER ?= minecraft
define USAGE
targets:
all build all Docker images (default)
clean remove all Docker images
help show this screen
machine targets:
<machine> build <machine> image
<machine> clean remove <machine> image
<machine> test provision and test <machine>
machines:
$(BOXES)
variables:
PROCESS_CONTROL Choose from 'supervisor' or 'systemd'. Default: 'systemd'.
SERVER Choose from 'minecraft' or 'spigot'. Default: 'minecraft'.
endef
is_machine_target = $(if $(findstring $(firstword $(MAKECMDGOALS)),$(BOXES)),true,false)
all:
docker-compose build
clean:
ifeq (true,$(call is_machine_target))
docker rmi -f ansibleminecraft_$(firstword $(MAKECMDGOALS))
else
-docker images -q ansibleminecraft* | xargs docker rmi -f
endif
help:
@echo $(info $(USAGE))
test:
ifeq (true,$(call is_machine_target))
./scripts/ci.sh $(firstword $(MAKECMDGOALS)) $(PROCESS_CONTROL) $(SERVER)
else
$(error `test` requires a machine name, see `make help`)
endif
$(BOXES):
# Don't build an image just to delete it.
ifeq (,$(findstring clean,$(lastword $(MAKECMDGOALS))))
{ docker images ansibleminecraft_$@ | grep $@; } && exit || docker-compose build $@
endif
.PHONY: all \
clean \
help \
test