added docker-compose and environment for queues

This commit is contained in:
YevhenBondarenko 2020-05-08 18:02:45 +03:00 committed by Andrew Shvayka
parent 7e66fd2693
commit 95ddde3e38
26 changed files with 451 additions and 52 deletions

View File

@ -1,3 +1,4 @@
TB_QUEUE_TYPE=kafka
DOCKER_REPO=thingsboard

View File

@ -32,6 +32,32 @@ function additionalComposeArgs() {
echo $ADDITIONAL_COMPOSE_ARGS
}
function additionalComposeQueueArgs() {
source .env
ADDITIONAL_COMPOSE_QUEUE_ARGS=""
case $TB_QUEUE_TYPE in
kafka)
ADDITIONAL_COMPOSE_QUEUE_ARGS="-f docker-compose.kafka.yml"
;;
aws-sqs)
ADDITIONAL_COMPOSE_QUEUE_ARGS="-f docker-compose.aws-sqs.yml"
;;
pubsub)
ADDITIONAL_COMPOSE_QUEUE_ARGS="-f docker-compose.pubsub.yml"
;;
rabbitmq)
ADDITIONAL_COMPOSE_QUEUE_ARGS="-f docker-compose.rabbitmq.yml"
;;
service-bus)
ADDITIONAL_COMPOSE_QUEUE_ARGS="-f docker-compose.service-bus.yml"
;;
*)
echo "Unknown Queue service value specified: '${TB_QUEUE_TYPE}'. Should be either kafka or aws-sqs or pubsub or rabbitmq or service-bus." >&2
exit 1
esac
echo $ADDITIONAL_COMPOSE_QUEUE_ARGS
}
function additionalStartupServices() {
source .env
ADDITIONAL_STARTUP_SERVICES=""

View File

@ -0,0 +1,71 @@
#
# Copyright © 2016-2020 The Thingsboard Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
version: '2.2'
services:
tb-js-executor:
env_file:
- queue-aws-sqs.env
tb-core1:
env_file:
- queue-aws-sqs.env
depends_on:
- zookeeper
- redis
tb-core2:
env_file:
- queue-aws-sqs.env
depends_on:
- zookeeper
- redis
tb-rule-engine1:
env_file:
- queue-aws-sqs.env
depends_on:
- zookeeper
- redis
tb-rule-engine2:
env_file:
- queue-aws-sqs.env
depends_on:
- zookeeper
- redis
tb-mqtt-transport1:
env_file:
- queue-aws-sqs.env
depends_on:
- zookeeper
tb-mqtt-transport2:
env_file:
- queue-aws-sqs.env
depends_on:
- zookeeper
tb-http-transport1:
env_file:
- queue-aws-sqs.env
depends_on:
- zookeeper
tb-http-transport2:
env_file:
- queue-aws-sqs.env
depends_on:
- zookeeper
tb-coap-transport:
env_file:
- queue-aws-sqs.env
depends_on:
- zookeeper

View File

@ -28,27 +28,27 @@ services:
env_file:
- tb-node.cassandra.env
depends_on:
- kafka
- zookeeper
- redis
- cassandra
tb-core2:
env_file:
- tb-node.cassandra.env
depends_on:
- kafka
- zookeeper
- redis
- cassandra
tb-rule-engine1:
env_file:
- tb-node.cassandra.env
depends_on:
- kafka
- zookeeper
- redis
- cassandra
tb-rule-engine2:
env_file:
- tb-node.cassandra.env
depends_on:
- kafka
- zookeeper
- redis
- cassandra

View File

@ -0,0 +1,82 @@
#
# Copyright © 2016-2020 The Thingsboard Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
version: '2.2'
services:
kafka:
restart: always
image: "wurstmeister/kafka:2.12-2.3.0"
ports:
- "9092:9092"
env_file:
- kafka.env
depends_on:
- zookeeper
tb-js-executor:
env_file:
- queue-kafka.env
depends_on:
- kafka
tb-core1:
env_file:
- queue-kafka.env
depends_on:
- kafka
- redis
tb-core2:
env_file:
- queue-kafka.env
depends_on:
- kafka
- redis
tb-rule-engine1:
env_file:
- queue-kafka.env
depends_on:
- kafka
- redis
tb-rule-engine2:
env_file:
- queue-kafka.env
depends_on:
- kafka
- redis
tb-mqtt-transport1:
env_file:
- queue-kafka.env
depends_on:
- kafka
tb-mqtt-transport2:
env_file:
- queue-kafka.env
depends_on:
- kafka
tb-http-transport1:
env_file:
- queue-kafka.env
depends_on:
- kafka
tb-http-transport2:
env_file:
- queue-kafka.env
depends_on:
- kafka
tb-coap-transport:
env_file:
- queue-kafka.env
depends_on:
- kafka

View File

@ -31,27 +31,27 @@ services:
env_file:
- tb-node.postgres.env
depends_on:
- kafka
- zookeeper
- redis
- postgres
tb-core2:
env_file:
- tb-node.postgres.env
depends_on:
- kafka
- zookeeper
- redis
- postgres
tb-rule-engine1:
env_file:
- tb-node.postgres.env
depends_on:
- kafka
- zookeeper
- redis
- postgres
tb-rule-engine2:
env_file:
- tb-node.postgres.env
depends_on:
- kafka
- zookeeper
- redis
- postgres

View File

@ -0,0 +1,71 @@
#
# Copyright © 2016-2020 The Thingsboard Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
version: '2.2'
services:
tb-js-executor:
env_file:
- queue-pubsub.env.env
tb-core1:
env_file:
- queue-pubsub.env.env
depends_on:
- zookeeper
- redis
tb-core2:
env_file:
- queue-pubsub.env
depends_on:
- zookeeper
- redis
tb-rule-engine1:
env_file:
- queue-pubsub.env
depends_on:
- zookeeper
- redis
tb-rule-engine2:
env_file:
- queue-pubsub.env
depends_on:
- zookeeper
- redis
tb-mqtt-transport1:
env_file:
- queue-pubsub.env
depends_on:
- zookeeper
tb-mqtt-transport2:
env_file:
- queue-pubsub.env
depends_on:
- zookeeper
tb-http-transport1:
env_file:
- queue-pubsub.env
depends_on:
- zookeeper
tb-http-transport2:
env_file:
- queue-pubsub.env
depends_on:
- zookeeper
tb-coap-transport:
env_file:
- queue-pubsub.env
depends_on:
- zookeeper

View File

@ -0,0 +1,71 @@
#
# Copyright © 2016-2020 The Thingsboard Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
version: '2.2'
services:
tb-js-executor:
env_file:
- queue-rabbitmq.env
tb-core1:
env_file:
- queue-rabbitmq.env
depends_on:
- zookeeper
- redis
tb-core2:
env_file:
- queue-rabbitmq.env
depends_on:
- zookeeper
- redis
tb-rule-engine1:
env_file:
- queue-rabbitmq.env
depends_on:
- zookeeper
- redis
tb-rule-engine2:
env_file:
- queue-rabbitmq.env
depends_on:
- zookeeper
- redis
tb-mqtt-transport1:
env_file:
- queue-rabbitmq.env
depends_on:
- zookeeper
tb-mqtt-transport2:
env_file:
- queue-rabbitmq.env
depends_on:
- zookeeper
tb-http-transport1:
env_file:
- queue-rabbitmq.env
depends_on:
- zookeeper
tb-http-transport2:
env_file:
- queue-rabbitmq.env
depends_on:
- zookeeper
tb-coap-transport:
env_file:
- queue-rabbitmq.env
depends_on:
- zookeeper

View File

@ -0,0 +1,71 @@
#
# Copyright © 2016-2020 The Thingsboard Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
version: '2.2'
services:
tb-js-executor:
env_file:
- queue-service-bus.env
tb-core1:
env_file:
- queue-service-bus.env
depends_on:
- zookeeper
- redis
tb-core2:
env_file:
- queue-service-bus.env
depends_on:
- zookeeper
- redis
tb-rule-engine1:
env_file:
- queue-service-bus.env
depends_on:
- zookeeper
- redis
tb-rule-engine2:
env_file:
- queue-service-bus.env
depends_on:
- zookeeper
- redis
tb-mqtt-transport1:
env_file:
- queue-service-bus.env
depends_on:
- zookeeper
tb-mqtt-transport2:
env_file:
- queue-service-bus.env
depends_on:
- zookeeper
tb-http-transport1:
env_file:
- queue-service-bus.env
depends_on:
- zookeeper
tb-http-transport2:
env_file:
- queue-service-bus.env
depends_on:
- zookeeper
tb-coap-transport:
env_file:
- queue-service-bus.env
depends_on:
- zookeeper

View File

@ -26,15 +26,6 @@ services:
environment:
ZOO_MY_ID: 1
ZOO_SERVERS: server.1=zookeeper:2888:3888;zookeeper:2181
kafka:
restart: always
image: "wurstmeister/kafka:2.12-2.3.0"
ports:
- "9092:9092"
env_file:
- kafka.env
depends_on:
- zookeeper
redis:
restart: always
image: redis:4.0
@ -43,11 +34,9 @@ services:
tb-js-executor:
restart: always
image: "${DOCKER_REPO}/${JS_EXECUTOR_DOCKER_NAME}:${TB_VERSION}"
scale: 20
scale: 2
env_file:
- tb-js-executor.env
depends_on:
- kafka
tb-core1:
restart: always
image: "${DOCKER_REPO}/${TB_NODE_DOCKER_NAME}:${TB_VERSION}"
@ -67,7 +56,7 @@ services:
- ./tb-node/conf:/config
- ./tb-node/log:/var/log/thingsboard
depends_on:
- kafka
- zookeeper
- redis
- tb-js-executor
- tb-rule-engine1
@ -91,7 +80,7 @@ services:
- ./tb-node/conf:/config
- ./tb-node/log:/var/log/thingsboard
depends_on:
- kafka
- zookeeper
- redis
- tb-js-executor
- tb-rule-engine1
@ -115,7 +104,7 @@ services:
- ./tb-node/conf:/config
- ./tb-node/log:/var/log/thingsboard
depends_on:
- kafka
- zookeeper
- redis
- tb-js-executor
tb-rule-engine2:
@ -137,7 +126,7 @@ services:
- ./tb-node/conf:/config
- ./tb-node/log:/var/log/thingsboard
depends_on:
- kafka
- zookeeper
- redis
- tb-js-executor
tb-mqtt-transport1:
@ -153,7 +142,7 @@ services:
- ./tb-transports/mqtt/conf:/config
- ./tb-transports/mqtt/log:/var/log/tb-mqtt-transport
depends_on:
- kafka
- zookeeper
tb-mqtt-transport2:
restart: always
image: "${DOCKER_REPO}/${MQTT_TRANSPORT_DOCKER_NAME}:${TB_VERSION}"
@ -167,7 +156,7 @@ services:
- ./tb-transports/mqtt/conf:/config
- ./tb-transports/mqtt/log:/var/log/tb-mqtt-transport
depends_on:
- kafka
- zookeeper
tb-http-transport1:
restart: always
image: "${DOCKER_REPO}/${HTTP_TRANSPORT_DOCKER_NAME}:${TB_VERSION}"
@ -181,7 +170,7 @@ services:
- ./tb-transports/http/conf:/config
- ./tb-transports/http/log:/var/log/tb-http-transport
depends_on:
- kafka
- zookeeper
tb-http-transport2:
restart: always
image: "${DOCKER_REPO}/${HTTP_TRANSPORT_DOCKER_NAME}:${TB_VERSION}"
@ -195,7 +184,7 @@ services:
- ./tb-transports/http/conf:/config
- ./tb-transports/http/log:/var/log/tb-http-transport
depends_on:
- kafka
- zookeeper
tb-coap-transport:
restart: always
image: "${DOCKER_REPO}/${COAP_TRANSPORT_DOCKER_NAME}:${TB_VERSION}"
@ -209,7 +198,7 @@ services:
- ./tb-transports/coap/conf:/config
- ./tb-transports/coap/log:/var/log/tb-coap-transport
depends_on:
- kafka
- zookeeper
tb-web-ui1:
restart: always
image: "${DOCKER_REPO}/${WEB_UI_DOCKER_NAME}:${TB_VERSION}"

View File

@ -41,14 +41,16 @@ set -e
source compose-utils.sh
ADDITIONAL_COMPOSE_QUEUE_ARGS=$(additionalComposeQueueArgs) || exit $?
ADDITIONAL_COMPOSE_ARGS=$(additionalComposeArgs) || exit $?
ADDITIONAL_STARTUP_SERVICES=$(additionalStartupServices) || exit $?
if [ ! -z "${ADDITIONAL_STARTUP_SERVICES// }" ]; then
docker-compose -f docker-compose.yml $ADDITIONAL_COMPOSE_ARGS up -d redis $ADDITIONAL_STARTUP_SERVICES
docker-compose -f docker-compose.yml $ADDITIONAL_COMPOSE_ARGS $ADDITIONAL_COMPOSE_QUEUE_ARGS up -d redis $ADDITIONAL_STARTUP_SERVICES
fi
docker-compose -f docker-compose.yml $ADDITIONAL_COMPOSE_ARGS run --no-deps --rm -e INSTALL_TB=true -e LOAD_DEMO=${loadDemo} tb-core1
docker-compose -f docker-compose.yml $ADDITIONAL_COMPOSE_ARGS $ADDITIONAL_COMPOSE_QUEUE_ARGS run --no-deps --rm -e INSTALL_TB=true -e LOAD_DEMO=${loadDemo} tb-core1

View File

@ -19,6 +19,8 @@ set -e
source compose-utils.sh
ADDITIONAL_COMPOSE_QUEUE_ARGS=$(additionalComposeQueueArgs) || exit $?
ADDITIONAL_COMPOSE_ARGS=$(additionalComposeArgs) || exit $?
docker-compose -f docker-compose.yml $ADDITIONAL_COMPOSE_ARGS down -v
docker-compose -f docker-compose.yml $ADDITIONAL_COMPOSE_ARGS $ADDITIONAL_COMPOSE_QUEUE_ARGS down -v

View File

@ -19,6 +19,8 @@ set -e
source compose-utils.sh
ADDITIONAL_COMPOSE_QUEUE_ARGS=$(additionalComposeQueueArgs) || exit $?
ADDITIONAL_COMPOSE_ARGS=$(additionalComposeArgs) || exit $?
docker-compose -f docker-compose.yml $ADDITIONAL_COMPOSE_ARGS up -d
docker-compose -f docker-compose.yml $ADDITIONAL_COMPOSE_ARGS $ADDITIONAL_COMPOSE_QUEUE_ARGS up -d

View File

@ -19,6 +19,8 @@ set -e
source compose-utils.sh
ADDITIONAL_COMPOSE_QUEUE_ARGS=$(additionalComposeQueueArgs) || exit $?
ADDITIONAL_COMPOSE_ARGS=$(additionalComposeArgs) || exit $?
docker-compose -f docker-compose.yml $ADDITIONAL_COMPOSE_ARGS stop
docker-compose -f docker-compose.yml $ADDITIONAL_COMPOSE_ARGS $ADDITIONAL_COMPOSE_QUEUE_ARGS stop

View File

@ -19,7 +19,9 @@ set -e
source compose-utils.sh
ADDITIONAL_COMPOSE_QUEUE_ARGS=$(additionalComposeQueueArgs) || exit $?
ADDITIONAL_COMPOSE_ARGS=$(additionalComposeArgs) || exit $?
docker-compose -f docker-compose.yml $ADDITIONAL_COMPOSE_ARGS pull $@
docker-compose -f docker-compose.yml $ADDITIONAL_COMPOSE_ARGS up -d --no-deps --build $@
docker-compose -f docker-compose.yml $ADDITIONAL_COMPOSE_ARGS $ADDITIONAL_COMPOSE_QUEUE_ARGS pull $@
docker-compose -f docker-compose.yml $ADDITIONAL_COMPOSE_ARGS $ADDITIONAL_COMPOSE_QUEUE_ARGS up -d --no-deps --build $@

View File

@ -40,12 +40,14 @@ set -e
source compose-utils.sh
ADDITIONAL_COMPOSE_QUEUE_ARGS=$(additionalComposeQueueArgs) || exit $?
ADDITIONAL_COMPOSE_ARGS=$(additionalComposeArgs) || exit $?
ADDITIONAL_STARTUP_SERVICES=$(additionalStartupServices) || exit $?
docker-compose -f docker-compose.yml $ADDITIONAL_COMPOSE_ARGS pull tb-core1
docker-compose -f docker-compose.yml $ADDITIONAL_COMPOSE_ARGS $ADDITIONAL_COMPOSE_QUEUE_ARGS pull tb-core1
docker-compose -f docker-compose.yml $ADDITIONAL_COMPOSE_ARGS up -d redis $ADDITIONAL_STARTUP_SERVICES
docker-compose -f docker-compose.yml $ADDITIONAL_COMPOSE_ARGS $ADDITIONAL_COMPOSE_QUEUE_ARGS up -d redis $ADDITIONAL_STARTUP_SERVICES
docker-compose -f docker-compose.yml $ADDITIONAL_COMPOSE_ARGS run --no-deps --rm -e UPGRADE_TB=true -e FROM_VERSION=${fromVersion} tb-core1
docker-compose -f docker-compose.yml $ADDITIONAL_COMPOSE_ARGS $ADDITIONAL_COMPOSE_QUEUE_ARGS run --no-deps --rm -e UPGRADE_TB=true -e FROM_VERSION=${fromVersion} tb-core1

4
docker/queue-aws-sqs.env Normal file
View File

@ -0,0 +1,4 @@
TB_QUEUE_TYPE=aws-sqs
TB_QUEUE_AWS_SQS_ACCESS_KEY_ID=YOUR_KEY
TB_QUEUE_AWS_SQS_SECRET_ACCESS_KEY=YOUR_SECRET
TB_QUEUE_AWS_SQS_REGION=YOUR_REGION

2
docker/queue-kafka.env Normal file
View File

@ -0,0 +1,2 @@
TB_QUEUE_TYPE=kafka
TB_KAFKA_SERVERS=kafka:9092

3
docker/queue-pubsub.env Normal file
View File

@ -0,0 +1,3 @@
TB_QUEUE_TYPE=pubsub
TB_QUEUE_PUBSUB_PROJECT_ID=YOUR_PROJECT_ID
TB_QUEUE_PUBSUB_SERVICE_ACCOUNT=YOUR_SERVICE_ACCOUNT

View File

@ -0,0 +1,5 @@
TB_QUEUE_TYPE=rabbitmq
TB_QUEUE_RABBIT_MQ_HOST=localhost
TB_QUEUE_RABBIT_MQ_PORT=5672
TB_QUEUE_RABBIT_MQ_USERNAME=YOUR_USERNAME
TB_QUEUE_RABBIT_MQ_PASSWORD=YOUR_PASSWORD

View File

@ -0,0 +1,4 @@
TB_QUEUE_TYPE=service-bus
TB_QUEUE_SERVICE_BUS_NAMESPACE_NAME=YOUR_NAMESPACE_NAME
TB_QUEUE_SERVICE_BUS_SAS_KEY_NAME=YOUR_SAS_KEY_NAME
TB_QUEUE_SERVICE_BUS_SAS_KEY=YOUR_SAS_KEY

View File

@ -4,6 +4,3 @@ ZOOKEEPER_URL=zookeeper:2181
COAP_BIND_ADDRESS=0.0.0.0
COAP_BIND_PORT=5683
COAP_TIMEOUT=10000
TB_QUEUE_TYPE=kafka
TB_KAFKA_SERVERS=kafka:9092

View File

@ -4,6 +4,3 @@ ZOOKEEPER_URL=zookeeper:2181
HTTP_BIND_ADDRESS=0.0.0.0
HTTP_BIND_PORT=8081
HTTP_REQUEST_TIMEOUT=60000
TB_QUEUE_TYPE=kafka
TB_KAFKA_SERVERS=kafka:9092

View File

@ -1,6 +1,4 @@
TB_QUEUE_TYPE=kafka
REMOTE_JS_EVAL_REQUEST_TOPIC=js_eval.requests
TB_KAFKA_SERVERS=kafka:9092
LOGGER_LEVEL=info
LOG_FOLDER=logs
LOGGER_FILENAME=tb-js-executor-%DATE%.log

View File

@ -4,6 +4,3 @@ ZOOKEEPER_URL=zookeeper:2181
MQTT_BIND_ADDRESS=0.0.0.0
MQTT_BIND_PORT=1883
MQTT_TIMEOUT=10000
TB_QUEUE_TYPE=kafka
TB_KAFKA_SERVERS=kafka:9092

View File

@ -2,8 +2,6 @@
ZOOKEEPER_ENABLED=true
ZOOKEEPER_URL=zookeeper:2181
TB_QUEUE_TYPE=kafka
TB_KAFKA_SERVERS=kafka:9092
JS_EVALUATOR=remote
TRANSPORT_TYPE=remote
CACHE_TYPE=redis