-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
114 lines (101 loc) · 3 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
.PHONY: start run up
d ?=
start run up: compose raw
# Start up all of the containers defined in our docker compose yaml. If Linux or
# MacOS is being used then the unix override will be applied so that the traffic
# control is able to work!
#
# The if filter expression is simply a way to check if the client os (as seen by
# docker) is linux or darwin
.PHONY: raw
raw:
# Start up all containers using an already created compose file.
@docker-compose \
-p dane -f built/docker-compose.yml \
$(if \
$(filter $(shell docker version -f {{.Client.Os}}),linux darwin),\
-f docker/compose/docker-compose.unix.yml,\
\
) \
up \
$(if $(d),-d,)
.PHONY: stop interrupt
name ?= dane_daemon_1
stop interrupt:
# Send a SIGINT signal to a container, defaulting to the daemon.
docker kill --signal SIGINT $(name)
.PHONY: down
down:
@docker-compose \
-p dane -f built/docker-compose.yml \
down \
--remove-orphans
.PHONY: compose
define first_time_msg
********************************************************************************
Looks like this may be your first time running DANE! Give us a moment to get the
tool ready for you. We just need to pull in a Docker image from Docker Hub.
********************************************************************************
endef
export first_time_msg
tool_dir ?=
config_file ?=
compose_image ?= parkeraddison/dane-compose
compose:
# Build the compose file from given configuration in config.py. We'll just use
# the image that's hosted on Docker Hub.
ifeq ($(shell docker images -q $(compose_image)),)
@echo "$$first_time_msg"
@docker pull $(compose_image)
endif
@docker run \
-it \
--rm \
-v "$(PWD):/home" \
$(compose_image) \
python setup/build_compose.py \
$(if $(tool_dir),--src $(tool_dir),) \
$(if $(config_file),-config $(config_file),)
.PHONY: build
tag ?= latest
only ?= all
build:
# Build all (or only some) images.
ifeq ($(only),all)
docker build \
-f docker/client/Dockerfile \
--build-arg BUILD_DATE="$(shell date --rfc-3339 seconds)" \
-t dane-client:$(tag) .
docker build \
-f docker/daemon/Dockerfile \
--build-arg BUILD_DATE="$(shell date --rfc-3339 seconds)" \
-t dane-daemon:$(tag) .
docker build \
-f docker/router/Dockerfile \
--build-arg BUILD_DATE="$(shell date --rfc-3339 seconds)" \
-t dane-router:$(tag) .
docker build \
-f docker/compose/Dockerfile \
--build-arg BUILD_DATE="$(shell date --rfc-3339 seconds)" \
-t dane-compose:$(tag) .
else
docker build \
-f docker/$(only)/Dockerfile \
--build-arg BUILD_DATE="$(shell date --rfc-3339 seconds)" \
-t dane-$(only):$(tag) .
endif
.PHONY: clean
clean: stop
# Make sure everything is stopped and remove all built images
docker rmi dane-client
docker rmi dane-daemon
docker rmi dane-router
docker rmi dane-compose
.PHONY: exec
service ?= daemon
command ?= sh
exec:
# Exec into a shell for a given service.
docker-compose \
-p dane -f built/docker-compose.yml \
exec $(service) $(command)