-
Notifications
You must be signed in to change notification settings - Fork 11
/
docker-compose.yml
129 lines (117 loc) · 2.6 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
version: '2.1'
# networks:
# backend: {}
services:
# abstract base class
elixir-base:
build:
context: .
dockerfile: Dockerfile.elixir-base
volumes:
- .:/workspace
working_dir: /workspace
environment:
- REDIS_HOST=redis
- REDIS_PORT=${REDIS_PORT}
- REDIS_TTL=${REDIS_TTL}
- COOKIE=SECRET
restart: "no"
env_file:
- .env
# redis: cluster registration and heartbeat tracker
redis:
image: redis
ports:
- ${REDIS_PORT}:${REDIS_PORT}
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:${REDIS_PORT}"]
interval: 1m30s
timeout: 10s
retries: 3
env_file:
- .env
# mix (elixir build tool) proxy/helpers: no need for elixir stack on dev host
deps.get:
extends: elixir-base
command: mix deps.get
compile:
extends: elixir-base
command: mix compile
test:
extends: elixir-base
command: mix test --cover
# worker: a.k.a Cluster.Worker in elixir world
worker:
extends: elixir-base
command: bash worker.sh
links:
- redis
environment:
- MIX_ENV=worker
# system monitor: display cluster statistics in a loop
sysmon:
extends: elixir-base
command: bash sysmon.sh
ports:
- 5984:5984 # consolex webserver
links:
- redis
environment:
- MIX_ENV=sysmon
# api: a web-based API
api:
extends: elixir-base
command: bash api.sh
expose:
- 5983
- 80
depends_on:
- redis
# ports:
# - 5983:5983 # api webserver
links:
- redis
environment:
- MIX_ENV=api
# load balancer
lb:
image: dockercloud/haproxy
depends_on:
- api
environment:
- ADDITIONAL_SERVICES=${COMPOSE_PROJECT_NAME}:api
volumes:
- /var/run/docker.sock:/var/run/docker.sock
ports:
- 80:80
# system monitor: display cluster statistics in a loop
loader:
extends: elixir-base
command: bash loader.sh
links:
- redis
environment:
- MIX_ENV=sysmon
# command shell: agent loop + iex terminal
shell:
extends: elixir-base
stdin_open: true
tty: true
command: bash shell.sh
environment:
- MIX_ENV=shell
links:
- redis
# WIP: doesn't work without X11 forwarding and XQuartz
# observer:
# extends: elixir-base
# stdin_open: true
# tty: true
# command: iex -S mix run -e ":observer.start"
# environment:
# - MIX_ENV=shell
# - DISPLAY=:0.0
# volumes:
# - /tmp/.X11-unix:/tmp/.X11-unix
# - ~/.Xauthority:/root/.Xauthority
# network_mode: "host"