-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
60 lines (44 loc) · 1.73 KB
/
Makefile
File metadata and controls
60 lines (44 loc) · 1.73 KB
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
VERSION ?= latest
HOST_IP := $(shell ifconfig en0 | grep "inet "| awk -F" " '{print $$2}')
.PHONY: pull build stop write_routes registrator consul rm
pull:
docker pull consul
docker pull gliderlabs/registrator
build:
(cd loginjs; docker build -t login-service .)
(cd cartjs; docker build -t cart-service .)
(cd catalogjs; docker build -t catalog-service .)
docker build -t cpx-consul-sidecar .
consul:
docker run --name consul -d -p 8400:8400 -p 8500:8500 -p 8600:53/udp -h ${HOST_IP} consul
registrator:
docker run --net=host --name registrator -d -h ${HOST_IP} -v /var/run/docker.sock:/tmp/docker.sock gliderlabs/registrator -cleanup -resync 5 consul://localhost:8500
write_routes:
docker run --net=host consul kv put widgetshop/services/login-service/route "/api/login/*"
docker run --net=host consul kv put widgetshop/services/cart-service/route "/api/cart/*"
docker run --net=host consul kv put widgetshop/services/catalog-service/route "/api/catalog/*"
run_microservices:
(cd app; docker-compose up -d)
run_cpx:
docker-compose up -d
stop:
docker-compose down
(cd app; docker-compose down)
docker stop registrator
docker stop consul
rm:
docker rm registrator
docker rm consul
sleep:
sleep 20
print_urls:
@echo "http://localhost:$$(docker port cpx 8088|awk -F':' '{print $$2}')/api/catalog/"
@echo "http://localhost:$$(docker port cpx 8088|awk -F':' '{print $$2}')/api/cart/"
@echo "http://localhost:$$(docker port cpx 8088|awk -F':' '{print $$2}')/api/login/"
all: pull build consul registrator sleep write_routes sleep run_microservices sleep run_cpx
image_cleanup:
docker rmi login-service
docker rmi cart-service
docker rmi catalog-service
docker rmi cpx-consul-sidecar
cleanup: stop rm image_cleanup