-
Notifications
You must be signed in to change notification settings - Fork 122
/
Makefile
52 lines (40 loc) · 1.72 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
NAME = ib
GATEWAY_IMAGE = $(NAME)_gateway_test
GATEWAY_CONT = $(GATEWAY_IMAGE)_c
TEST_CONT = $(NAME)_test_c
IB_LOGIN ?= fdemo
IB_PASSWORD ?= demouser
all : test
.build_gw_id : testserver
docker build -t $(GATEWAY_IMAGE) testserver
@docker inspect -f '{{.Id}}' $(GATEWAY_IMAGE) > .build_gw_id
.gateway_id : .build_gw_id
-@docker rm -f $(GATEWAY_CONT) > /dev/null 2> /dev/null || true
-@docker rm -f $(GATEWAY_CONT)_tmp > /dev/null 2> /dev/null || true
docker run --name $(GATEWAY_CONT) -e IB_LOGIN=$(IB_LOGIN) -e IB_PASSWORD=$(IB_PASSWORD) -d $(GATEWAY_IMAGE)
@echo Wait for Gateway to be started
@sleep 1
@docker run --link $(GATEWAY_CONT):gw --rm --name $(GATEWAY_CONT)_tmp -t ubuntu:14.04 \
bash -c 'for i in {1..60}; do \
echo | nc $$GW_PORT_4003_TCP_ADDR 4002 && exit 0 || (echo -n ..; sleep 1); \
done; \
echo; \
echo Waiting for Gateway timed out; exit 1'
@echo
@docker inspect -f '{{.Id}}' $(GATEWAY_IMAGE) > .gateway_id
gateway : .gateway_id
.build_id : .
docker build -t $(NAME) .
@docker inspect -f '{{.Id}}' $(GATEWAY_IMAGE) > .build_id
build : .build_id
test : gateway build
-@docker rm -f $(TEST_CONT) > /dev/null 2> /dev/null || true
docker run --link $(GATEWAY_CONT):gw --name $(TEST_CONT) -t $(NAME) bash -c 'cd /src && go test $(TESTFLAGS) -gw $$GW_PORT_4003_TCP_ADDR:4003'
clean :
-@docker rm -f $(GATEWAY_CONT) > /dev/null 2> /dev/null || true
-@docker rm -f $(GATEWAY_CONT)_tmp > /dev/null 2> /dev/null || true
-@docker rm -f $(TEST_CONT) > /dev/null 2> /dev/null || true
clean_all : clean
-@rm -f .build_id .build_gw_id .gateway_id
re : clean_all all
.PHONY : all gateway buld test clean clean_all re