-
Notifications
You must be signed in to change notification settings - Fork 6
/
docker-compose.yml
216 lines (201 loc) · 8.15 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
###############################################################################
# Copyright (c) 2021 Ashwin Krishnan
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of MIT and is provided "as is",
# without warranty of any kind, express or implied, including but
# not limited to the warranties of merchantability, fitness for a
# particular purpose and noninfringement. In no event shall the
# authors, contributors or copyright holders be liable for any claim,
# damages or other liability, whether in an action of contract,
# tort or otherwise, arising from, out of or in connection with the software
# or the use or other dealings in the software.
#
# Contributors:
# -
###############################################################################
# This is a docker-compose to rapidly deploy all uns modules and assosciates services needed for deployment
# DO NOT USE FOR PRODUCTION DELPOYMENT
# This currently ignores the configurations present in the conf folders and uses the defaults for all configurations
# Except for passwords of the databases which need to be provided as enviorment variables while running this compose file
# Env Variables which have to be set are
# - UNS_graphdb__password
# - UNS_historian__password
# - PGPASSWORD
# Example for running this would be
# UNS_graphdb__password=<password1> UNS_historian__password=<password1> PGPASSWORD=<password3> docker-compose up -d
# Example for destroying all the containers and volumes created
# UNS_graphdb__password=<password1> UNS_historian__password=<password1> PGPASSWORD=<password3> docker-compose down --volumes
version: '3'
services:
uns_mqtt_broker:
image: emqx/emqx:latest
ports:
- "1883:1883"
- "8083:8083"
healthcheck:
test: ["CMD", "/opt/emqx/bin/emqx", "ctl", "status"]
interval: 5s
timeout: 25s
retries: 5
uns_timescale_db:
image: timescale/timescaledb:latest-pg16
ports:
- "5432:5432"
environment:
POSTGRES_PASSWORD: ${PGPASSWORD}
healthcheck:
test: "pg_isready --username=postgres && psql --username=postgres --list"
timeout: 10s
retries: 20
uns_neo4j_db:
image: neo4j:latest
ports:
- "7474:7474"
- "7687:7687"
environment:
NEO4J_AUTH: neo4j/${UNS_graphdb__password}
apoc.export.file.enabled: "true"
apoc.import.file.enabled: "true"
apoc.import.file.use_neo4j_config: "true"
NEO4J_PLUGINS: '["apoc"]'
healthcheck:
test: wget http://localhost:7474 || exit 1
interval: 1s
timeout: 10s
retries: 20
start_period: 3s
uns_kakfa_broker:
image: bitnami/kafka:latest
ports:
- "9092:9092"
environment:
ALLOW_PLAINTEXT_LISTENER: "yes"
KAFKA_ADVERTISED_LISTENERS: "PLAINTEXT://localhost:9092"
KAFKA_CFG_NODE_ID: 0
KAFKA_CFG_PROCESS_ROLES: controller,broker
KAFKA_CFG_LISTENERS: PLAINTEXT://:9092,CONTROLLER://:9093
KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT
KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: 0@uns_kakfa_broker:9093
KAFKA_CFG_CONTROLLER_LISTENER_NAMES: CONTROLLER
healthcheck:
test: kafka-topics.sh --bootstrap-server uns_kakfa_broker:9092 --topic hc --create --if-not-exists && kafka-topics.sh --bootstrap-server uns_kakfa_broker:9092 --topic hc --describe
start_period: 10s
interval: 5s
timeout: 10s
retries: 5
tsdb_setup_script:
image: postgres:12
environment:
PGPASSWORD: ${PGPASSWORD}
UNS_historian__hostname: uns_timescale_db
UNS_historian__database: "uns_historian"
UNS_historian__table: "unifiednamespace"
UNS_historian__username: uns_dbuser
UNS_historian__password: ${UNS_historian__password}
depends_on:
uns_timescale_db:
condition: service_healthy
command:
- /bin/bash
- -c
- |
PGPASSWORD=$${PGPASSWORD} psql -h $${UNS_historian__hostname} -U postgres -p 5432 -c "CREATE DATABASE $${UNS_historian__database};"
PGPASSWORD=$${PGPASSWORD} psql -h $${UNS_historian__hostname} -U postgres -p 5432 -d $${UNS_historian__database} -c "CREATE EXTENSION IF NOT EXISTS timescaledb;"
PGPASSWORD=$${PGPASSWORD} psql -h $${UNS_historian__hostname} -U postgres -p 5432 -c "CREATE ROLE $${UNS_historian__username} LOGIN PASSWORD '$${UNS_historian__password}';"
PGPASSWORD=$${PGPASSWORD} psql -h $${UNS_historian__hostname} -U postgres -p 5432 -c "ALTER DATABASE $${UNS_historian__database} OWNER TO $${UNS_historian__username};"
PGPASSWORD=$${UNS_historian__password} psql -h $${UNS_historian__hostname} -U $${UNS_historian__username} -d $${UNS_historian__database} -p 5432 -c "CREATE TABLE $${UNS_historian__table} (time TIMESTAMPTZ NOT NULL, topic TEXT NOT NULL, client_id TEXT, mqtt_msg JSONB, CONSTRAINT unique_event UNIQUE (time, topic, client_id, mqtt_msg));"
PGPASSWORD=$${UNS_historian__password} psql -h $${UNS_historian__hostname} -U $${UNS_historian__username} -d $${UNS_historian__database} -p 5432 -c "SELECT create_hypertable('$${UNS_historian__table}', 'time');"
echo "Successfully created & configured timescaledb for the UNS"
graphdb_client:
build:
context: .
dockerfile: ./03_uns_graphdb/Dockerfile
# volumes:
# - ./conf:/app/conf
environment:
UNS_MODULE: 03_uns_graphdb
UNS_mqtt__host: uns_mqtt_broker
UNS_graphdb__url: bolt://uns_neo4j_db:7687
UNS_graphdb__username: neo4j
UNS_graphdb__password: ${UNS_graphdb__password}
depends_on:
uns_mqtt_broker:
condition: service_healthy
uns_neo4j_db:
condition: service_healthy
historian_client:
build:
context: .
dockerfile: ./04_uns_historian/Dockerfile
# volumes:
# - ./conf:/app/conf
environment:
UNS_MODULE: 04_uns_historian
UNS_mqtt__host: uns_mqtt_broker
UNS_historian__hostname: uns_timescale_db
UNS_historian__database: "uns_historian"
UNS_historian__table: "unifiednamespace"
UNS_historian__username: uns_dbuser
UNS_historian__password: ${UNS_historian__password}
depends_on:
uns_mqtt_broker:
condition: service_healthy
uns_timescale_db:
condition: service_healthy
tsdb_setup_script:
condition: service_completed_successfully
spb_mapper_client:
build:
context: .
dockerfile: ./05_sparkplugb/Dockerfile
# volumes:
# - ./conf:/app/conf
environment:
UNS_MODULE: 05_sparkplugb
UNS_mqtt__host: uns_mqtt_broker
depends_on:
uns_mqtt_broker:
condition: service_healthy
kafka_mapper_client:
build:
context: .
dockerfile: ./06_uns_kafka/Dockerfile
# volumes:
# - ./conf:/app/conf
environment:
UNS_MODULE: 06_uns_kafka
UNS_mqtt__host: uns_mqtt_broker
UNS_kafka__config: '@json {"client.id": "uns_kafka_client", "bootstrap.servers": "uns_kakfa_broker:9092", "enable.idempotence": true, "retries": 10, "compression.type": "gzip"}'
depends_on:
uns_mqtt_broker:
condition: service_healthy
uns_kakfa_broker:
condition: service_healthy
graphql_server:
build:
context: .
dockerfile: ./07_uns_graphql/Dockerfile
# volumes:
# - ./conf:/app/conf
environment:
UNS_MODULE: 07_uns_graphql
UNS_mqtt__host: uns_mqtt_broker
UNS_graphdb__url: bolt://uns_neo4j_db:7687
UNS_graphdb__username: neo4j
UNS_graphdb__password: ${UNS_graphdb__password}
UNS_historian__hostname: uns_timescale_db
UNS_historian__database: "uns_historian"
UNS_historian__table: "unifiednamespace"
UNS_historian__username: uns_dbuser
UNS_historian__password: ${UNS_historian__password}
UNS_kafka__config: '@json {"group.id": "uns_graphql", "client.id": "uns_graphql_client", "bootstrap.servers": "uns_kakfa_broker:9092", "enable.idempotence": true, "retries": 10, "compression.type": "gzip"}'
depends_on:
uns_mqtt_broker:
condition: service_healthy
uns_neo4j_db:
condition: service_healthy
uns_timescale_db:
condition: service_healthy
uns_kakfa_broker:
condition: service_healthy