forked from suvash/hulaaki
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
56 lines (40 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
.DEFAULT_GOAL:=test
PROJECT_NAME:=hulaaki
DEV_PROJECT_IMAGE_NAME:=$(PROJECT_NAME)/dev
MQTT_SERVER_IMAGE_NAME:=ansi/mosquitto
MQTT_SERVER_NAME:=mosquitto
CONTAINER_WORKDIR:=$(shell grep WORKDIR Dockerfile | cut -d' ' -f2)
HOST_DIR:=$(CURDIR)
MQTT_PORT:=1883
MQTT_HOST:=hulaaki_mqtt
DOCKER_ENV:=\
-e MQTT_HOST=$(MQTT_HOST) \
-e MQTT_PORT=$(MQTT_PORT)
DOCKER_LINK:=\
--link $(MQTT_SERVER_NAME):$(MQTT_HOST) \
DOCKER_VOLUME:=\
-v $(HOST_DIR):$(CONTAINER_WORKDIR)
DOCKER_INTERACTIVE_RUN:=\
docker run --rm -it \
$(DOCKER_ENV) \
$(DOCKER_LINK) \
$(DOCKER_VOLUME) \
$(DEV_PROJECT_IMAGE_NAME)
.PHONY: mqtt-server dev clean run bash test
mqtt-server-start:
docker run -d -p $(MQTT_PORT):$(MQTT_PORT) --name $(MQTT_SERVER_NAME) $(MQTT_SERVER_IMAGE_NAME)
mqtt-server-stop:
docker stop $(MQTT_SERVER_NAME)
docker rm $(MQTT_SERVER_NAME)
dev: Dockerfile
$(info **** Building docker dev environment image $(DEV_PROJECT_IMAGE_NAME))
docker build -t $(DEV_PROJECT_IMAGE_NAME) .
clean:
$(info **** Cleaning up images)
docker rmi $(DEV_PROJECT_IMAGE_NAME)
run: dev
$(if $(CMD), $(DOCKER_INTERACTIVE_RUN) $(CMD), $(error -- CMD must be set))
bash: CMD=/bin/bash
bash: run
test: CMD=mix test
test: run