-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yml
244 lines (225 loc) · 5.72 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
version: "3.8"
services:
# control:
# container_name: "control_panel"
# depends_on:
# - accounts
# - locations
# - readings
# Accounts Service
accounts_db:
image: postgres:15.3-alpine3.18
container_name: "accounts_db"
ports:
- 5432:5432
restart: always
secrets:
- db-password
environment:
POSTGRES_DB: accounts_example_db
POSTGRES_USER: postgres
PGUSER: postgres
POSTGRES_PASSWORD_FILE: /run/secrets/db-password
volumes:
- accounts_pg:/var/lib/postgresql/data
- accounts_db:/docker-entrypoint-initdb.d
healthcheck:
test: [ "CMD", "pg_isready" ]
interval: 10s
timeout: 5s
retries: 5
networks:
- backend
accounts:
container_name: "accounts_service"
depends_on: ["accounts_db", "adminer"]
build:
context: ./services/accounts/.
dockerfile: Dockerfile
ports:
- 3000:3000
networks:
- backend
# Locations Service
locations_db:
image: postgres:15.3-alpine3.18
container_name: "locations_db"
ports:
- 5433:5432
restart: always
secrets:
- db-password
environment:
POSTGRES_DB: locations_example_db
POSTGRES_USER: postgres
PGUSER: postgres
POSTGRES_PASSWORD_FILE: /run/secrets/db-password
volumes:
- locations_pg:/var/lib/postgresql/data
- locations_db:/docker-entrypoint-initdb.d
healthcheck:
test: [ "CMD", "pg_isready" ]
interval: 10s
timeout: 5s
retries: 5
networks:
- backend
locations:
container_name: "locations_service"
depends_on: ["locations_db"]
build:
context: ./services/locations/.
dockerfile: Dockerfile
ports:
- 3001:3000
networks:
- backend
# Readings Service
readings_db:
image: postgres:15.3-alpine3.18
container_name: "readings_db"
ports:
- 5434:5432
restart: always
secrets:
- db-password
environment:
POSTGRES_DB: readings_example_db
POSTGRES_USER: postgres
PGUSER: postgres
POSTGRES_PASSWORD_FILE: /run/secrets/db-password
volumes:
- readings_pg:/var/lib/postgresql/data
- readings_db:/docker-entrypoint-initdb.d
healthcheck:
test: [ "CMD", "pg_isready" ]
interval: 10s
timeout: 5s
retries: 5
networks:
- backend
readings:
container_name: "readings_service"
depends_on: ["readings_db"]
build:
context: ./services/readings/.
dockerfile: Dockerfile
ports:
- 3002:3000
networks:
- backend
iot_devices:
container_name: "iot_devices"
# depends_on: []
build:
context: ./services/iot-devices/.
dockerfile: Dockerfile
ports:
- 3003:3000
networks:
- backend
adminer:
image: adminer
container_name: "postgres_adminer"
depends_on: ["accounts_db", "locations_db", "readings_db"]
restart: always
ports:
- 8080:8080
networks:
- backend
zookeeper:
image: "confluentinc/cp-zookeeper:latest"
container_name: zookeeper
hostname: zookeeper
restart: always
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
# requires SSL setup
# ZOOKEEPER_SECURE_CLIENT_PORT: 2182
networks:
- backend
volumes:
- ./scripts/security:/etc/kafka/s
broker:
image: 'confluentinc/cp-kafka:latest'
hostname: broker
container_name: broker
ports:
- 9092:9092
depends_on: ["zookeeper"]
networks:
- backend
environment:
KAFKA_ZOOKEEPER_CONNECT: "zookeeper:2181"
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_INTERNAL:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
# 1st must be localhost, but the 2nd may be localhost or 'broker' -> container_name
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092,PLAINTEXT_INTERNAL://broker:29092
# KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR default is 3
# if replication factor is > # of brokers, then we get an error when consume attempts to grab messages from the queue
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
# Start Docker Compose and view logs for other env variables to set
KAFKA_NUM_PARTITIONS: 1
# OPTIONAL?
# KAFKA_BROKER_ID: 1
# KAFKA_CONFLUENT_LICENSE_TOPIC_REPLICATION_FACTOR: 1
# KAFKA_CONFLUENT_BALANCER_TOPIC_REPLICATION_FACTOR: 1
# KAFKA_DELETE_TOPIC_ENABLE: "true"
# KAFKA_AUTO_CREATE_TOPICS_ENABLE: "true"
# TOPIC_AUTO_CREATE: true
# KAFKA_CONFLUENT_SUPPORT_METRICS_ENABLE: "false"
networks:
default:
backend:
volumes:
zookeeper:
driver: local
driver_opts:
type: "none"
o: "bind"
device: "./services/zookeeper/data"
accounts_pg:
driver: local
driver_opts:
type: "none"
o: "bind"
device: "./services/accounts/pg_data"
accounts_db:
driver: local
driver_opts:
type: "none"
o: "bind"
device: "./services/accounts/database"
locations_pg:
driver: local
driver_opts:
type: "none"
o: "bind"
device: "./services/locations/pg_data"
locations_db:
driver: local
driver_opts:
type: "none"
o: "bind"
device: "./services/locations/database"
readings_pg:
driver: local
driver_opts:
type: "none"
o: "bind"
device: "./services/readings/pg_data"
readings_db:
driver: local
driver_opts:
type: "none"
o: "bind"
device: "./services/readings/database"
secrets:
db-password:
file: secrets/db-password.txt
# command: tail -f /dev/null
# working_dir: /usr/src/app
# command: ["go build -o main ./cmd/accounts/.", "main"]
# volumes:
# - .:/usr/src/app