-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocker-compose.yaml
242 lines (239 loc) · 7.18 KB
/
docker-compose.yaml
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
version: "3"
networks:
knowstr:
driver: bridge
services:
traefik:
networks:
- knowstr
image: traefik:v3.0
ports:
- 3001:3001
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
command:
- "--providers.docker"
- "--entrypoints.web.address=:3001"
reader:
networks:
- knowstr
labels:
- "traefik.enable=false"
environment:
KNOWSTR_REDIS_URL: ${KNOWSTR_REDIS_URL:-redis://redis:6379}
KNOWSTR_PULSAR_URL: ${KNOWSTR_PULSAR_URL:-pulsar://broker:6650}
build:
context: ./examples/reader
depends_on:
redis:
condition: service_healthy
broker:
condition: service_started
scheduler:
networks:
- knowstr
labels:
- "traefik.enable=false"
restart: unless-stopped
command: npm run scheduler
environment:
KNOWSTR_REDIS_URL: ${KNOWSTR_REDIS_URL:-redis://redis:6379}
build:
context: .
depends_on:
redis:
condition: service_healthy
zookeeper:
condition: service_healthy
bookie:
condition: service_started
worker:
networks:
- knowstr
labels:
- "traefik.enable=false"
restart: unless-stopped
command: npm run worker
environment:
KNOWSTR_REDIS_URL: ${KNOWSTR_REDIS_URL:-redis://redis:6379}
KNOWSTR_PULSAR_URL: ${KNOWSTR_PULSAR_URL:-pulsar://broker:6650}
KNOWSTR_KNOWSTR_FOLLOW_REDIRECTS: "true"
build:
context: .
deploy:
replicas: 3
depends_on:
scheduler:
condition: service_started
redis:
condition: service_healthy
zookeeper:
condition: service_healthy
bookie:
condition: service_started
web:
networks:
- knowstr
restart: unless-stopped
command: npm run web
environment:
KNOWSTR_REDIS_URL: ${KNOWSTR_REDIS_URL:-redis://redis:6379}
KNOWSTR_PULSAR_URL: ${KNOWSTR_PULSAR_URL:-pulsar://broker:6650}
KNOWSTR_BROKER_API_URL: ${KNOWSTR_BROKER_API_URL:-http://broker:8080}
labels:
- "traefik.enable=true"
- "traefik.http.services.web.loadbalancer.server.port=3000"
- "traefik.http.routers.web.entrypoints=web"
- "traefik.http.routers.web.rule=Host(`localhost`)"
- "traefik.http.routers.web.middlewares=auth"
- "traefik.http.middlewares.auth.basicauth.users=knowstr:$$2y$$05$$X9Tw/O1rh5K/oFbZLLt8c.X0fZe1JyN4hdbHCWk4adGORLoLd9goO"
build:
context: .
deploy:
replicas: 1
depends_on:
scheduler:
condition: service_started
redis:
condition: service_healthy
zookeeper:
condition: service_healthy
bookie:
condition: service_started
redis:
networks:
- knowstr
labels:
- "traefik.enable=false"
image: redis:7
volumes:
- ./docker/redis-data:/data
command: redis-server --io-threads 4 --io-threads-do-reads yes --appendonly no --maxmemory-policy noeviction --bind 0.0.0.0 --maxclients 10000 --tcp-backlog 511
healthcheck:
test: ["CMD", "redis-cli", "--raw", "incr", "ping"]
interval: 3s
timeout: 5s
retries: 5
# Start zookeeper
zookeeper:
networks:
- knowstr
labels:
- "traefik.enable=false"
image: apachepulsar/pulsar:3.1.1
container_name: zookeeper
user: root
restart: on-failure
volumes:
- ./docker/zookeeper-data:/pulsar/data/zookeeper
environment:
- metadataStoreUrl=zk:zookeeper:2181
- PULSAR_MEM=-Xms256m -Xmx256m -XX:MaxDirectMemorySize=256m
command: >
bash -c "bin/apply-config-from-env.py conf/zookeeper.conf && \
bin/generate-zookeeper-config.sh conf/zookeeper.conf && \
exec bin/pulsar zookeeper"
healthcheck:
test: ["CMD", "bin/pulsar-zookeeper-ruok.sh"]
interval: 10s
timeout: 5s
retries: 30
# # Init cluster metadata
pulsar-init:
networks:
- knowstr
labels:
- "traefik.enable=false"
container_name: pulsar-init
hostname: pulsar-init
image: apachepulsar/pulsar:3.1.1
command: >
bin/pulsar initialize-cluster-metadata \
--cluster cluster-a \
--zookeeper zookeeper:2181 \
--configuration-store zookeeper:2181 \
--web-service-url http://broker:8080 \
--broker-service-url pulsar://broker:6650
depends_on:
zookeeper:
condition: service_healthy
# # Start bookie
bookie:
networks:
- knowstr
labels:
- "traefik.enable=false"
image: apachepulsar/pulsar:3.1.1
container_name: bookie
restart: on-failure
environment:
- clusterName=cluster-a
- zkServers=zookeeper:2181
- metadataServiceUri=metadata-store:zk:zookeeper:2181
# otherwise every time we run docker compose uo or down we fail to start due to Cookie
# See: https://github.com/apache/bookkeeper/blob/405e72acf42bb1104296447ea8840d805094c787/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Cookie.java#L57-68
- advertisedAddress=bookie
- BOOKIE_MEM=-Xms512m -Xmx512m -XX:MaxDirectMemorySize=256m
depends_on:
zookeeper:
condition: service_healthy
pulsar-init:
condition: service_completed_successfully
# Map the local directory to the container to avoid bookie startup failure due to insufficient container disks.
volumes:
- ./docker/bookkeeper-data:/pulsar/data/bookkeeper
command: bash -c "bin/apply-config-from-env.py conf/bookkeeper.conf && exec bin/pulsar bookie"
# # Start broker
broker:
networks:
- knowstr
labels:
- "traefik.enable=false"
image: apachepulsar/pulsar:3.1.1
container_name: broker
hostname: broker
restart: on-failure
environment:
- metadataStoreUrl=zk:zookeeper:2181
- zookeeperServers=zookeeper:2181
- clusterName=cluster-a
- managedLedgerDefaultEnsembleSize=1
- managedLedgerDefaultWriteQuorum=1
- managedLedgerDefaultAckQuorum=1
- advertisedAddress=${KNOWSTR_PULSAR_ADVERTISED_ADDRESS:-broker}
- advertisedListeners=${KNOWSTR_PULSAR_ADVERTISED_LISTENERS:-external:pulsar://127.0.0.1:6650,internal:pulsar://broker:6650}
- internalListenerName=${KNOWSTR_PULSAR_INTERNAL_LISTENER_NAME:-internal}
- PULSAR_MEM=-Xms512m -Xmx512m -XX:MaxDirectMemorySize=256m
depends_on:
zookeeper:
condition: service_healthy
bookie:
condition: service_started
command: bash -c "bin/apply-config-from-env.py conf/broker.conf && exec bin/pulsar broker"
dashboard:
networks:
- knowstr
labels:
- "traefik.enable=false"
image: apachepulsar/pulsar-manager:v0.2.0
ports:
- "9527:9527"
depends_on:
- broker
links:
- broker
environment:
SPRING_CONFIGURATION_FILE: /pulsar-manager/pulsar-manager/application.properties
dashboard-setup:
networks:
- knowstr
labels:
- "traefik.enable=false"
image: quay.io/curl/curl:latest
restart: on-failure
depends_on:
dashboard:
condition: service_started
command: sh -c 'chmod +x /scripts/dashboard-setup.sh && /scripts/dashboard-setup.sh'
volumes:
- ./docker/scripts/dashboard-setup.sh:/scripts/dashboard-setup.sh