Skip to content

Commit

Permalink
Create single instance docker builds. Move MSA docker configuration t…
Browse files Browse the repository at this point in the history
…o the root.
  • Loading branch information
ikulikov committed Oct 24, 2018
1 parent e51cafa commit 00e8961
Show file tree
Hide file tree
Showing 68 changed files with 1,606 additions and 1,529 deletions.
25 changes: 15 additions & 10 deletions docker/.env
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
# cassandra environment variables
CASSANDRA_DATA_DIR=/home/docker/cassandra_volume

# postgres environment variables
POSTGRES_DATA_DIR=/home/docker/postgres_volume
POSTGRES_DB=thingsboard
DOCKER_REPO=thingsboard

# hsqldb environment variables
HSQLDB_DATA_DIR=/home/docker/hsqldb_volume
JS_EXECUTOR_DOCKER_NAME=tb-js-executor
TB_NODE_DOCKER_NAME=tb-node
WEB_UI_DOCKER_NAME=tb-web-ui
MQTT_TRANSPORT_DOCKER_NAME=tb-mqtt-transport
HTTP_TRANSPORT_DOCKER_NAME=tb-http-transport
COAP_TRANSPORT_DOCKER_NAME=tb-coap-transport

# environment variables for schema init and insert system and demo data
ADD_SCHEMA_AND_SYSTEM_DATA=false
ADD_DEMO_DATA=false
TB_VERSION=latest

# Database used by ThingsBoard, can be either local (local HSQLDB), postgres (PostgreSQL), cassandra (Cassandra).
# In case of postgres or cassandra corresponding docker service will be deployed (see docker-compose.postgres.yml, docker-compose.cassandra.yml for details).

DATABASE=cassandra

KAFKA_TOPICS="js.eval.requests:100:1:delete --config=retention.ms=60000 --config=segment.bytes=26214400 --config=retention.bytes=104857600,tb.transport.api.requests:30:1:delete --config=retention.ms=60000 --config=segment.bytes=26214400 --config=retention.bytes=104857600,tb.rule-engine:30:1"
2 changes: 2 additions & 0 deletions msa/docker/.gitignore → docker/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ haproxy/certs.d/**
haproxy/letsencrypt/**
tb-node/log/**
tb-node/db/**
tb-node/postgres/**
tb-node/cassandra/**
!.env
51 changes: 51 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Docker configuration for ThingsBoard Microservices

This folder containing scripts and Docker Compose configurations to run ThingsBoard in Microservices mode.

## Installation

Execute the following command to run DataBase installation:

`
$ ./docker-install-tb.sh --loadDemo
`

- `--loadDemo` - optional argument. Whether to load additional demo data.

## Running

Execute the following command to run services:

`
$ ./docker-start-services.sh
`

Execute the following command to stop services:

`
$ ./docker-stop-services.sh
`

Execute the following command to stop and completely remove deployed docker containers:

`
$ ./docker-remove-services.sh
`

Execute the following command to update particular services (pull newer docker image and rebuild container):

`
$ ./docker-update-service.sh [SERVICE...]
`

## Upgrading

In case when database upgrade is needed, execute the following commands:

`
$ ./docker-stop-services.sh
$ ./docker-upgrade-tb.sh --fromVersion=[FROM_VERSION]
$ ./docker-start-services.sh
`

- `FROM_VERSION` - from which version upgrade should be started.
12 changes: 0 additions & 12 deletions docker/cassandra-setup/Makefile

This file was deleted.

12 changes: 0 additions & 12 deletions docker/cassandra-upgrade/Makefile

This file was deleted.

10 changes: 0 additions & 10 deletions docker/cassandra/Makefile

This file was deleted.

28 changes: 0 additions & 28 deletions docker/cassandra/ready-probe.sh

This file was deleted.

2 changes: 1 addition & 1 deletion msa/docker/check-dirs.sh → docker/check-dirs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.
#

dirsArray=("./haproxy/certs.d" "./haproxy/letsencrypt" "./tb-node/db" "./tb-node/log")
dirsArray=("./haproxy/certs.d" "./haproxy/letsencrypt" "./tb-node/db" "./tb-node/postgres" "./tb-node/cassandra" "./tb-node/log")

for dir in ${dirsArray[@]}
do
Expand Down
54 changes: 54 additions & 0 deletions docker/compose-utils.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash
#
# Copyright © 2016-2018 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.
#

function additionalComposeArgs() {
source .env
ADDITIONAL_COMPOSE_ARGS=""
case $DATABASE in
local)
;;
postgres)
ADDITIONAL_COMPOSE_ARGS="-f docker-compose.postgres.yml"
;;
cassandra)
ADDITIONAL_COMPOSE_ARGS="-f docker-compose.cassandra.yml"
;;
*)
echo "Unknown DATABASE value specified: '${DATABASE}'. Should be either local, postgres or cassandra." >&2
exit 1
esac
echo $ADDITIONAL_COMPOSE_ARGS
}

function additionalStartupServices() {
source .env
ADDITIONAL_STARTUP_SERVICES=""
case $DATABASE in
local)
;;
postgres)
ADDITIONAL_STARTUP_SERVICES=postgres
;;
cassandra)
ADDITIONAL_STARTUP_SERVICES=cassandra
;;
*)
echo "Unknown DATABASE value specified: '${DATABASE}'. Should be either local, postgres or cassandra." >&2
exit 1
esac
echo $ADDITIONAL_STARTUP_SERVICES
}
34 changes: 34 additions & 0 deletions docker/docker-compose.cassandra.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#
# Copyright © 2016-2018 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:
cassandra:
restart: always
image: "cassandra:3.11.3"
ports:
- "9042"
volumes:
- ./tb-node/cassandra:/var/lib/cassandra
tb:
environment:
DATABASE_TS_TYPE: cassandra
DATABASE_ENTITIES_TYPE: cassandra
CASSANDRA_URL: cassandra:9042
depends_on:
- kafka
- cassandra
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,27 @@
# limitations under the License.
#

version: '3.3'
services:
zookeeper:
image: wurstmeister/zookeeper
networks:
- core
ports:
- "2181:2181"

cassandra:
image: cassandra:3.11.2
networks:
- core
ports:
- "7199:7199"
- "9160:9160"
- "9042:9042"
version: '2.2'

redis:
image: redis:4.0
networks:
- core
command: redis-server --maxclients 2000
services:
postgres:
restart: always
image: "postgres:9.6"
ports:
- "6379:6379"

networks:
core:

- "5432"
environment:
POSTGRES_DB: thingsboard
volumes:
- ./tb-node/postgres:/var/lib/postgresql/data
tb:
environment:
DATABASE_TS_TYPE: sql
DATABASE_ENTITIES_TYPE: sql
SPRING_JPA_DATABASE_PLATFORM: org.hibernate.dialect.PostgreSQLDialect
SPRING_DRIVER_CLASS_NAME: org.postgresql.Driver
SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/thingsboard
SPRING_DATASOURCE_USERNAME: postgres
SPRING_DATASOURCE_PASSWORD: postgres
depends_on:
- kafka
- postgres
Loading

0 comments on commit 00e8961

Please sign in to comment.