-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yml
287 lines (267 loc) · 8 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
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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
version: '3.8'
services:
zookeeper:
image: confluentinc/cp-zookeeper:7.3.0
hostname: zookeeper
container_name: zookeeper
ports:
- "2181:2181"
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
# Kafka broker
# Visible to localhost on port 29092. Visible to other containers on port 9092.
kafka:
image: confluentinc/cp-kafka:7.3.0
hostname: kafka
container_name: kafka
depends_on:
- zookeeper
ports:
- "29092:29092"
expose :
- "9092"
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181'
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092,PLAINTEXT_HOST://localhost:29092
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
KAFKA_TOOLS_LOG4J_LOGLEVEL: ERROR
# Container to initialize Kafka topics via CLI
init-kafka:
image: confluentinc/cp-kafka:7.3.0
depends_on:
- kafka
entrypoint: [ '/bin/sh', '-c' ]
command: |
"
# blocks until kafka is reachable
kafka-topics --bootstrap-server kafka:9092 --list
echo -e 'Creating kafka topics'
kafka-topics --bootstrap-server kafka:9092 --create --if-not-exists --topic ship-data-topic --replication-factor 1 --partitions 1
kafka-topics --bootstrap-server kafka:9092 --create --if-not-exists --topic ship-event-topic --replication-factor 1 --partitions 1
echo -e 'Successfully created the following topics:'
kafka-topics --bootstrap-server kafka:9092 --list
"
schema-registry:
image: confluentinc/cp-schema-registry:7.3.0
hostname: schema-registry
container_name: schema-registry
depends_on:
- kafka
ports:
- "8081:8081"
environment:
SCHEMA_REGISTRY_HOST_NAME: schema-registry
SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS: 'kafka:9092'
SCHEMA_REGISTRY_LOG4J_ROOT_LOGLEVEL: WARN
postgres:
image: postgres
hostname: postgres
container_name: postgres
restart: always
environment:
- PGUSER=postgres
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=ship_db
volumes:
- pgdata:/var/lib/postgresql/data
- ./backend/migrations/create_tables.sql:/docker-entrypoint-initdb.d/create_tables.sql
ports:
- "5432:5432"
logging:
options:
max-size: 10m
max-file: "3"
healthcheck:
test: ["CMD-SHELL", "pg_isready"]
interval: 1s
timeout: 5s
retries: 10
postgres-test:
image: postgres
hostname: postgres-test
container_name: postgres-test
restart: always
environment:
- PGUSER=postgres
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=ship_db
volumes:
- ./backend/migrations/create_tables.sql:/docker-entrypoint-initdb.d/create_tables.sql
ports:
- "5433:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready"]
interval: 1s
timeout: 5s
retries: 10
pgadmin:
hostname: pgadmin
container_name: pgadmin
image: dpage/pgadmin4
restart: always
environment:
PGADMIN_DEFAULT_EMAIL: admin@admin.com
PGADMIN_DEFAULT_PASSWORD: admin
ports:
- "5050:80"
volumes:
- ./pgadmin4/servers.json:/pgadmin4/servers.json
- pgadmin_data:/var/lib/pgadmin
elasticsearch:
hostname: elasticsearch
container_name: elasticsearch
image: elasticsearch:8.8.0
ports:
- 9200:9200 # Elasticsearch HTTP (for requests)
- 9300:9300 # Elasticsearch TCP transport (for communication between nodes within the cluster)
environment:
- discovery.type=single-node
- xpack.security.enabled=false
- cluster.name=ship-locator
volumes:
- elasticsearch-data:/usr/share/elasticsearch/data
prometheus:
hostname: prometheus
container_name: prometheus
image: prom/prometheus:v2.46.0
ports:
- 9090:9090 # Prometheus UI
- 9464:9464 # OpenTelemetry Collector
volumes:
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
grafana:
hostname: grafana
container_name: grafana
image: grafana/grafana:10.1.0
ports:
- 3002:3000
environment:
- GF_SECURITY_ADMIN_PASSWORD=admin
volumes:
- ./grafana/provisioning:/etc/grafana/provisioning
- ./grafana/dashboards:/var/lib/grafana/dashboards
otel-collector:
hostname: otel-collector
container_name: otel-collector
image: otel/opentelemetry-collector-contrib
volumes:
- ./otel/otel-collector-config.yaml:/etc/otelcol-contrib/config.yaml
ports:
- "1888:1888" # pprof extension
- "8888:8888" # Prometheus metrics exposed by the collector
- "8889:8889" # Prometheus exporter metrics
- "13133:13133" # health_check extension
- "4317:4317" # OTLP gRPC receiver
- "4318:4318" # OTLP http receiver
- "55679:55679" # zpages extension
depends_on:
- jaeger
jaeger:
hostname: jaeger
container_name: jaeger
image: jaegertracing/all-in-one:latest
ports:
- "16686:16686" # frontend
- "14268:14268" # [collector] accept jaeger.thrift directly from clients
- "14250:14250" # [collector] accept model.proto
- "9411:9411" # [collector] Zipkin compatible endpoint
environment:
- LOG_LEVEL=debug
- COLLECTOR_ZIPKIN_HTTP_PORT=9411
collector:
hostname: collector
container_name: collector
build:
context: ./backend
dockerfile: Dockerfile
target: collector
environment:
- SHIPLOC_WEBSOCKETAPIKEY
- SHIPLOC_KAFKAADDRESS=kafka:9092
command: ./collector
depends_on:
- kafka
restart: unless-stopped
ship-data-service:
hostname: ship-data-service
container_name: ship-data-service
build:
context: ./backend
dockerfile: Dockerfile
target: service
environment:
- SHIPLOC_KAFKAADDRESS=kafka:9092
- SHIPLOC_POSTGRESADDRESS=postgres:5432
- SHIPLOC_TRACINGCOLLECTORADDRESS=otel-collector:4318
- SHIPLOC_ELASTICSEARCHADDRESS=http://elasticsearch:9200
command: ./service
ports:
- "8086:8086" # GraphQL API
depends_on:
- kafka
- init-kafka
- postgres
- otel-collector
restart: unless-stopped
ship-search-service:
hostname: ship-search-service
container_name: ship-search-service
build:
context: ./backend
dockerfile: Dockerfile
target: search-service
environment:
- SHIPLOC_KAFKAADDRESS=kafka:9092
- SHIPLOC_TRACINGCOLLECTORADDRESS=otel-collector:4318
- SHIPLOC_ELASTICSEARCHADDRESS=http://elasticsearch:9200
command: ./search-service
ports:
- "8087:8087" # GraphQL API
depends_on:
- kafka
- init-kafka
- otel-collector
- elasticsearch
restart: unless-stopped
# GraphQL federated API that presents the APIs from the ship-data-service and ship-search-service as a single API
gateway:
hostname: gateway
container_name: gateway
build:
context: ./backend
dockerfile: Dockerfile
target: gateway
volumes:
- ./backend/gateway-config.json:/app/gateway-config.json
command: [ "./gateway", "-config", "/app/gateway-config.json" ]
environment:
- BRAMBLE_SERVICE_LIST=http://ship-data-service:8086/graphql http://ship-search-service:8087/graphql
ports:
- 8085:8085 # Gateway port (that federated API is served on)
- 8088:8088 # Private port (for admin interface)
- 8082:8082 # GraphQL Playground
- 8083:8083 # GraphQL Voyager
- 9009:9009 # GraphQL Schema
depends_on:
- ship-data-service
dashboard:
hostname: dashboard
container_name: dashboard
build:
context: ./frontend/dashboard
dockerfile: Dockerfile
environment:
- REACT_APP_GOOGLE_MAPS_API_KEY
ports:
- "3001:3000"
restart: unless-stopped
volumes:
pgdata:
pgadmin_data:
elasticsearch-data: