-
Notifications
You must be signed in to change notification settings - Fork 2
/
docker-compose.yml
107 lines (96 loc) · 3.68 KB
/
docker-compose.yml
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
version: '2'
networks:
micronet:
services:
nginx-service:
restart : always
build : ./nginx/
container_name: nginx-template-test
networks : [ micronet ]
working_dir : /usr/local/app/nginx-consul-template/
volumes :
- "./nginx/consul.ctmpl:/usr/local/app/nginx-consul-template/consul.ctmpl"
- "./nginx/nginx-template.sh:/usr/local/app/nginx-consul-template/nginx-template.sh"
environment:
- SERVICE_IGNORE=always
- CONSUL_AGENT_ADDR=${DOCKER_MACHINE_IP}
- CONSUL_AGENT_PORT=8500
ports :
- "80:80"
depends_on: [ call-server ]
command: [ "./nginx-template.sh" ]
# Consul
consul-bootstrap:
image : consul
container_name : consul-bootstrap
command :
- "agent"
- "-server"
- "-bootstrap"
- "-ui"
- "-data-dir=/tmp"
- "-advertise=${DOCKER_MACHINE_IP}" # Advertise using host environment variable ${DOCKER_MACHINE_IP}
# so that we could do `curl $(docker-machine ip):8500/v1/catalog/services`
- "-client=0.0.0.0"
- "-node=bootstrap-node"
volumes : [ "./.tmp/consul-bootstrap:/tmp/consul" ]
networks : [ micronet ]
environment :
- SERVICE_IGNORE=always
ports :
- "8400:8400"
- "8500:8500"
- "8600:8600/udp"
# Registrator
registrator:
image : gliderlabs/registrator
container_name: registrator
command : ["-ip", "${DOCKER_MACHINE_IP}", "consul://consul-bootstrap:8500"]
volumes : [ "/var/run/docker.sock:/tmp/docker.sock" ]
networks : [ micronet ]
depends_on : [ consul-bootstrap ]
# Flask services
hello-server:
build : .
container_name: hello-server
working_dir : /usr/local/app/consul-docker-test
volumes :
- "./flask-server:/usr/local/app/consul-docker-test/flask-server"
- "./uwsgi:/usr/local/app/consul-docker-test/uwsgi"
command : [ "uwsgi", "--ini", "uwsgi/uwsgi.ini:hello-server" ]
networks : [ micronet ]
ports : [ "5000:5000" ]
environment :
- SERVICE_NAME=hello-server
- SERVICE_TAGS=microservice
- CONSUL_AGENT_ADDR=${DOCKER_MACHINE_IP}
- CONSUL_AGENT_PORT=8500
depends_on : [ registrator ]
# Our call-server that will use consul to discover hello-server and perform REST request to hello-server
call-server:
build : .
container_name: call-server
working_dir : /usr/local/app/consul-docker-test
volumes :
- "./flask-server:/usr/local/app/consul-docker-test/flask-server"
- "./uwsgi:/usr/local/app/consul-docker-test/uwsgi"
command : [ "uwsgi", "--ini", "uwsgi/uwsgi.ini:call-server" ]
networks : [ micronet ]
ports : [ "5000" ]
environment :
- SERVICE_NAME=call-server
- SERVICE_TAGS=microservice
- CONSUL_AGENT_ADDR=${DOCKER_MACHINE_IP}
- CONSUL_AGENT_PORT=8500
depends_on : [ registrator ]
# pinger:
# build :
# context : .
# dockerfile: pinger-Dockerfile
# container_name: pinger
# networks : [ micronet ]
# links : [ consul-bootstrap ]
# dns : ["$DOCKER_MACHINE_IP"]
# dns_search : [ "service.consul" ]
# # command: ["cat", "/etc/resolv.conf"]
# command : ["curl", "-s", "consul-bootstrap:8500/v1/catalog/service/hello-server" ]