diff --git a/docker/.env b/docker/.env index e3306324d4..17f8af8c4e 100644 --- a/docker/.env +++ b/docker/.env @@ -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 \ No newline at end of file +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" diff --git a/msa/docker/.gitignore b/docker/.gitignore similarity index 65% rename from msa/docker/.gitignore rename to docker/.gitignore index c9843dc5a5..bc09e846b0 100644 --- a/msa/docker/.gitignore +++ b/docker/.gitignore @@ -2,4 +2,6 @@ haproxy/certs.d/** haproxy/letsencrypt/** tb-node/log/** tb-node/db/** +tb-node/postgres/** +tb-node/cassandra/** !.env diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 0000000000..23ff9b22cc --- /dev/null +++ b/docker/README.md @@ -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. diff --git a/docker/cassandra-setup/Makefile b/docker/cassandra-setup/Makefile deleted file mode 100644 index 7990a3e7e8..0000000000 --- a/docker/cassandra-setup/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -VERSION=2.1.0 -PROJECT=thingsboard -APP=cassandra-setup - -build: - cp ../../application/target/thingsboard.deb . - docker build --pull -t ${PROJECT}/${APP}:${VERSION} -t ${PROJECT}/${APP}:latest . - rm thingsboard.deb - -push: build - docker push ${PROJECT}/${APP}:${VERSION} - docker push ${PROJECT}/${APP}:latest diff --git a/docker/cassandra-upgrade/Makefile b/docker/cassandra-upgrade/Makefile deleted file mode 100644 index b2e8501a2b..0000000000 --- a/docker/cassandra-upgrade/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -VERSION=2.1.0 -PROJECT=thingsboard -APP=cassandra-upgrade - -build: - cp ../../application/target/thingsboard.deb . - docker build --pull -t ${PROJECT}/${APP}:${VERSION} -t ${PROJECT}/${APP}:latest . - rm thingsboard.deb - -push: build - docker push ${PROJECT}/${APP}:${VERSION} - docker push ${PROJECT}/${APP}:latest diff --git a/docker/cassandra/Makefile b/docker/cassandra/Makefile deleted file mode 100644 index d1fb67705f..0000000000 --- a/docker/cassandra/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -VERSION=2.1.0 -PROJECT=thingsboard -APP=cassandra - -build: - docker build --pull -t ${PROJECT}/${APP}:${VERSION} -t ${PROJECT}/${APP}:latest . - -push: build - docker push ${PROJECT}/${APP}:${VERSION} - docker push ${PROJECT}/${APP}:latest diff --git a/docker/cassandra/ready-probe.sh b/docker/cassandra/ready-probe.sh deleted file mode 100644 index 8533b6a6d1..0000000000 --- a/docker/cassandra/ready-probe.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env 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. -# - -if [[ $(nodetool status | grep $POD_IP) == *"UN"* ]]; then - if [[ $DEBUG ]]; then - echo "UN"; - fi - exit 0; -else - if [[ $DEBUG ]]; then - echo "Not Up"; - fi - exit 1; -fi \ No newline at end of file diff --git a/msa/docker/check-dirs.sh b/docker/check-dirs.sh similarity index 92% rename from msa/docker/check-dirs.sh rename to docker/check-dirs.sh index 9c683e6a51..6ae3f880a4 100755 --- a/msa/docker/check-dirs.sh +++ b/docker/check-dirs.sh @@ -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 diff --git a/docker/compose-utils.sh b/docker/compose-utils.sh new file mode 100755 index 0000000000..02a8e393e1 --- /dev/null +++ b/docker/compose-utils.sh @@ -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 +} diff --git a/docker/docker-compose.cassandra.yml b/docker/docker-compose.cassandra.yml new file mode 100644 index 0000000000..2bfb748b16 --- /dev/null +++ b/docker/docker-compose.cassandra.yml @@ -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 diff --git a/docker/cluster-mode-thirdparty.yml b/docker/docker-compose.postgres.yml similarity index 50% rename from docker/cluster-mode-thirdparty.yml rename to docker/docker-compose.postgres.yml index 3aa5bb5959..e2f2737b07 100644 --- a/docker/cluster-mode-thirdparty.yml +++ b/docker/docker-compose.postgres.yml @@ -14,32 +14,27 @@ # limitations under the License. # -version: '3.3' +version: '2.2' + services: - zookeeper: - image: wurstmeister/zookeeper - networks: - - core + postgres: + restart: always + image: "postgres:9.6" ports: - - "2181:2181" - - cassandra: - image: cassandra:3.11.2 - networks: - - core - ports: - - "7199:7199" - - "9160:9160" - - "9042:9042" - - redis: - image: redis:4.0 - networks: - - core - command: redis-server --maxclients 2000 - 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 diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 89a83696f3..a319606c03 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -14,40 +14,167 @@ # limitations under the License. # -version: '2' + +version: '2.2' services: - tb: - image: "thingsboard/application:2.1.0" - ports: - - "8080:8080" - - "1883:1883" - - "5683:5683/udp" - env_file: - - tb.env - environment: - - ADD_SCHEMA_AND_SYSTEM_DATA=${ADD_SCHEMA_AND_SYSTEM_DATA} - - ADD_DEMO_DATA=${ADD_DEMO_DATA} - volumes: - - "${HSQLDB_DATA_DIR}:/usr/share/thingsboard/data/sql" - entrypoint: /run-application.sh - cassandra: - image: "cassandra:3.11.2" - ports: - - "9042" - - "9160" - volumes: - - "${CASSANDRA_DATA_DIR}:/var/lib/cassandra" - zk: - image: "zookeeper:3.4.10" + zookeeper: + restart: always + image: "wurstmeister/zookeeper" ports: - "2181" + kafka: restart: always - postgres: - image: "postgres:9.6" + image: "wurstmeister/kafka" ports: - - "5432" + - "9092:9092" environment: - - POSTGRES_DB=${POSTGRES_DB} + KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 + KAFKA_LISTENERS: INSIDE://:9093,OUTSIDE://:9092 + KAFKA_ADVERTISED_LISTENERS: INSIDE://:9093,OUTSIDE://kafka:9092 + KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INSIDE:PLAINTEXT,OUTSIDE:PLAINTEXT + KAFKA_INTER_BROKER_LISTENER_NAME: INSIDE + KAFKA_CREATE_TOPICS: "${KAFKA_TOPICS}" + KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'false' + KAFKA_LOG_RETENTION_BYTES: 1073741824 + KAFKA_LOG_SEGMENT_BYTES: 268435456 + KAFKA_LOG_RETENTION_MS: 300000 + KAFKA_LOG_CLEANUP_POLICY: delete + depends_on: + - zookeeper + tb-js-executor: + restart: always + image: "${DOCKER_REPO}/${JS_EXECUTOR_DOCKER_NAME}:${TB_VERSION}" + scale: 20 + environment: + TB_KAFKA_SERVERS: kafka:9092 + env_file: + - tb-js-executor.env + depends_on: + - kafka + tb: + restart: always + image: "${DOCKER_REPO}/${TB_NODE_DOCKER_NAME}:${TB_VERSION}" + ports: + - "8080" + logging: + driver: "json-file" + options: + max-size: "200m" + max-file: "30" + env_file: + - tb-node.env + environment: + ZOOKEEPER_URL: zk:2181 + TB_KAFKA_SERVERS: kafka:9092 + JS_EVALUATOR: remote + DATABASE_TS_TYPE: sql + DATABASE_ENTITIES_TYPE: sql + SQL_DATA_FOLDER: /usr/share/thingsboard/data/db volumes: - - "${POSTGRES_DATA_DIR}:/var/lib/postgresql/data" + - ./tb-node/db:/usr/share/thingsboard/data/db + - ./tb-node/conf:/config + - ./tb-node/log:/var/log/thingsboard + depends_on: + - kafka + tb-mqtt-transport1: + restart: always + image: "${DOCKER_REPO}/${MQTT_TRANSPORT_DOCKER_NAME}:${TB_VERSION}" + ports: + - "1883" + environment: + TB_KAFKA_SERVERS: kafka:9092 + env_file: + - tb-mqtt-transport.env + depends_on: + - kafka + tb-mqtt-transport2: + restart: always + image: "${DOCKER_REPO}/${MQTT_TRANSPORT_DOCKER_NAME}:${TB_VERSION}" + ports: + - "1883" + environment: + TB_KAFKA_SERVERS: kafka:9092 + env_file: + - tb-mqtt-transport.env + depends_on: + - kafka + tb-http-transport1: + restart: always + image: "${DOCKER_REPO}/${HTTP_TRANSPORT_DOCKER_NAME}:${TB_VERSION}" + ports: + - "8081" + environment: + TB_KAFKA_SERVERS: kafka:9092 + env_file: + - tb-http-transport.env + depends_on: + - kafka + tb-http-transport2: + restart: always + image: "${DOCKER_REPO}/${HTTP_TRANSPORT_DOCKER_NAME}:${TB_VERSION}" + ports: + - "8081" + environment: + TB_KAFKA_SERVERS: kafka:9092 + env_file: + - tb-http-transport.env + depends_on: + - kafka + tb-coap-transport: + restart: always + image: "${DOCKER_REPO}/${COAP_TRANSPORT_DOCKER_NAME}:${TB_VERSION}" + ports: + - "5683:5683/udp" + environment: + TB_KAFKA_SERVERS: kafka:9092 + env_file: + - tb-coap-transport.env + depends_on: + - kafka + tb-web-ui1: + restart: always + image: "${DOCKER_REPO}/${WEB_UI_DOCKER_NAME}:${TB_VERSION}" + ports: + - "8080" + environment: + TB_HOST: tb + TB_PORT: 8080 + env_file: + - tb-web-ui.env + tb-web-ui2: + restart: always + image: "${DOCKER_REPO}/${WEB_UI_DOCKER_NAME}:${TB_VERSION}" + ports: + - "8080" + environment: + TB_HOST: tb + TB_PORT: 8080 + env_file: + - tb-web-ui.env + web: + restart: always + container_name: haproxy-certbot + image: nmarus/haproxy-certbot + volumes: + - ./haproxy/config:/config + - ./haproxy/letsencrypt:/etc/letsencrypt + - ./haproxy/certs.d:/usr/local/etc/haproxy/certs.d + ports: + - "80:80" + - "443:443" + - "1883:1883" + - "9999:9999" + cap_add: + - NET_ADMIN + environment: + HTTP_PORT: 80 + HTTPS_PORT: 443 + MQTT_PORT: 1883 + links: + - tb-web-ui1 + - tb-web-ui2 + - tb-mqtt-transport1 + - tb-mqtt-transport2 + - tb-http-transport1 + - tb-http-transport2 diff --git a/msa/docker/docker-install-tb.sh b/docker/docker-install-tb.sh similarity index 66% rename from msa/docker/docker-install-tb.sh rename to docker/docker-install-tb.sh index 5f34cc345f..4d4b9b9732 100755 --- a/msa/docker/docker-install-tb.sh +++ b/docker/docker-install-tb.sh @@ -39,6 +39,18 @@ else loadDemo=false fi -docker-compose run --no-deps --rm -e INSTALL_TB=true -e LOAD_DEMO=${loadDemo} tb +set -e + +source compose-utils.sh + +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 $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 diff --git a/docker/cassandra-setup/Dockerfile b/docker/docker-remove-services.sh old mode 100644 new mode 100755 similarity index 77% rename from docker/cassandra-setup/Dockerfile rename to docker/docker-remove-services.sh index c3f7ddb725..f80a73f9cd --- a/docker/cassandra-setup/Dockerfile +++ b/docker/docker-remove-services.sh @@ -1,3 +1,4 @@ +#!/bin/bash # # Copyright © 2016-2018 The Thingsboard Authors # @@ -14,11 +15,10 @@ # limitations under the License. # -FROM openjdk:8-jre +set -e -ADD install.sh /install.sh -ADD thingsboard.deb /thingsboard.deb +source compose-utils.sh -RUN apt-get update \ - && apt-get install -y nmap \ - && chmod +x /install.sh +ADDITIONAL_COMPOSE_ARGS=$(additionalComposeArgs) || exit $? + +docker-compose -f docker-compose.yml $ADDITIONAL_COMPOSE_ARGS down -v diff --git a/msa/docker/docker-start-services.sh b/docker/docker-start-services.sh similarity index 79% rename from msa/docker/docker-start-services.sh rename to docker/docker-start-services.sh index 44093934cd..8437695a1a 100755 --- a/msa/docker/docker-start-services.sh +++ b/docker/docker-start-services.sh @@ -17,4 +17,10 @@ ./check-dirs.sh -docker-compose up -d +set -e + +source compose-utils.sh + +ADDITIONAL_COMPOSE_ARGS=$(additionalComposeArgs) || exit $? + +docker-compose -f docker-compose.yml $ADDITIONAL_COMPOSE_ARGS up -d diff --git a/msa/docker/docker-stop-services.sh b/docker/docker-stop-services.sh similarity index 79% rename from msa/docker/docker-stop-services.sh rename to docker/docker-stop-services.sh index 673a0b2dfc..63dc6cbebc 100755 --- a/msa/docker/docker-stop-services.sh +++ b/docker/docker-stop-services.sh @@ -15,4 +15,10 @@ # limitations under the License. # -docker-compose stop +set -e + +source compose-utils.sh + +ADDITIONAL_COMPOSE_ARGS=$(additionalComposeArgs) || exit $? + +docker-compose -f docker-compose.yml $ADDITIONAL_COMPOSE_ARGS stop diff --git a/docker/cassandra-upgrade/Dockerfile b/docker/docker-update-service.sh old mode 100644 new mode 100755 similarity index 69% rename from docker/cassandra-upgrade/Dockerfile rename to docker/docker-update-service.sh index 312db0d4e3..e8702760ab --- a/docker/cassandra-upgrade/Dockerfile +++ b/docker/docker-update-service.sh @@ -1,3 +1,4 @@ +#!/bin/bash # # Copyright © 2016-2018 The Thingsboard Authors # @@ -14,11 +15,11 @@ # limitations under the License. # -FROM openjdk:8-jre +set -e -ADD upgrade.sh /upgrade.sh -ADD thingsboard.deb /thingsboard.deb +source compose-utils.sh -RUN apt-get update \ - && apt-get install -y nmap \ - && chmod +x /upgrade.sh +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 $@ diff --git a/msa/docker/docker-upgrade-tb.sh b/docker/docker-upgrade-tb.sh similarity index 68% rename from msa/docker/docker-upgrade-tb.sh rename to docker/docker-upgrade-tb.sh index 51202a6b0b..500b09a81e 100755 --- a/msa/docker/docker-upgrade-tb.sh +++ b/docker/docker-upgrade-tb.sh @@ -38,4 +38,16 @@ else fromVersion="${FROM_VERSION// }" fi -docker-compose run --no-deps --rm -e UPGRADE_TB=true -e FROM_VERSION=${fromVersion} tb +set -e + +source compose-utils.sh + +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 $ADDITIONAL_STARTUP_SERVICES +fi + +docker-compose -f docker-compose.yml $ADDITIONAL_COMPOSE_ARGS run --no-deps --rm -e UPGRADE_TB=true -e FROM_VERSION=${fromVersion} tb diff --git a/msa/docker/haproxy/config/haproxy.cfg b/docker/haproxy/config/haproxy.cfg similarity index 100% rename from msa/docker/haproxy/config/haproxy.cfg rename to docker/haproxy/config/haproxy.cfg diff --git a/docker/k8s/cassandra-setup.yaml b/docker/k8s/cassandra-setup.yaml deleted file mode 100644 index 03a2739446..0000000000 --- a/docker/k8s/cassandra-setup.yaml +++ /dev/null @@ -1,43 +0,0 @@ -# -# 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. -# - -apiVersion: v1 -kind: Pod -metadata: - name: cassandra-setup -spec: - containers: - - name: cassandra-setup - imagePullPolicy: Always - image: thingsboard/cassandra-setup:2.1.0 - env: - - name: ADD_DEMO_DATA - value: "true" - - name : CASSANDRA_HOST - value: "cassandra-headless" - - name : CASSANDRA_PORT - value: "9042" - - name : DATABASE_ENTITIES_TYPE - value: "cassandra" - - name : DATABASE_TS_TYPE - value: "cassandra" - - name : CASSANDRA_URL - value: "cassandra-headless:9042" - command: - - sh - - -c - - /install.sh - restartPolicy: Never diff --git a/docker/k8s/cassandra-upgrade.yaml b/docker/k8s/cassandra-upgrade.yaml deleted file mode 100644 index 9276776678..0000000000 --- a/docker/k8s/cassandra-upgrade.yaml +++ /dev/null @@ -1,45 +0,0 @@ -# -# 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. -# - -apiVersion: v1 -kind: Pod -metadata: - name: cassandra-upgrade -spec: - containers: - - name: cassandra-upgrade - imagePullPolicy: Always - image: thingsboard/cassandra-upgrade:2.1.0 - env: - - name: ADD_DEMO_DATA - value: "true" - - name : CASSANDRA_HOST - value: "cassandra-headless" - - name : CASSANDRA_PORT - value: "9042" - - name : DATABASE_ENTITIES_TYPE - value: "cassandra" - - name : DATABASE_TS_TYPE - value: "cassandra" - - name : CASSANDRA_URL - value: "cassandra-headless:9042" - - name : UPGRADE_FROM_VERSION - value: "1.4.0" - command: - - sh - - -c - - /upgrade.sh - restartPolicy: Never diff --git a/docker/k8s/cassandra.yaml b/docker/k8s/cassandra.yaml deleted file mode 100644 index 3165bb1a7a..0000000000 --- a/docker/k8s/cassandra.yaml +++ /dev/null @@ -1,132 +0,0 @@ -# -# 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. -# - -apiVersion: v1 -kind: Service -metadata: - name: cassandra-headless - labels: - app: cassandra-headless -spec: - ports: - - port: 9042 - name: cql - clusterIP: None - selector: - app: cassandra ---- -apiVersion: "apps/v1beta1" -kind: StatefulSet -metadata: - name: cassandra -spec: - serviceName: cassandra-headless - replicas: 2 - template: - metadata: - labels: - app: cassandra - spec: - nodeSelector: - machinetype: other - affinity: - podAntiAffinity: - requiredDuringSchedulingIgnoredDuringExecution: - - labelSelector: - matchExpressions: - - key: "app" - operator: In - values: - - cassandra-headless - topologyKey: "kubernetes.io/hostname" - containers: - - name: cassandra - image: thingsboard/cassandra:2.1.0 - imagePullPolicy: Always - ports: - - containerPort: 7000 - name: intra-node - - containerPort: 7001 - name: tls-intra-node - - containerPort: 7199 - name: jmx - - containerPort: 9042 - name: cql - - containerPort: 9160 - name: thrift - securityContext: - capabilities: - add: - - IPC_LOCK - lifecycle: - preStop: - exec: - command: ["/bin/sh", "-c", "PID=$(pidof java) && kill $PID && while ps -p $PID > /dev/null; do sleep 1; done"] - env: - - name: MAX_HEAP_SIZE - value: 2048M - - name: HEAP_NEWSIZE - value: 100M - - name: CASSANDRA_SEEDS - value: "cassandra-0.cassandra-headless.default.svc.cluster.local" - - name: CASSANDRA_CLUSTER_NAME - value: "Thingsboard-Cluster" - - name: CASSANDRA_DC - value: "DC1-Thingsboard-Cluster" - - name: CASSANDRA_RACK - value: "Rack-Thingsboard-Cluster" - - name: CASSANDRA_AUTO_BOOTSTRAP - value: "false" - - name: POD_IP - valueFrom: - fieldRef: - fieldPath: status.podIP - - name: POD_NAMESPACE - valueFrom: - fieldRef: - fieldPath: metadata.namespace - readinessProbe: - exec: - command: - - /bin/bash - - -c - - /ready-probe.sh - initialDelaySeconds: 15 - timeoutSeconds: 5 - volumeMounts: - - name: cassandra-data - mountPath: /var/lib/cassandra/data - - name: cassandra-commitlog - mountPath: /var/lib/cassandra/commitlog - volumeClaimTemplates: - - metadata: - name: cassandra-data - annotations: - volume.beta.kubernetes.io/storage-class: fast - spec: - accessModes: [ "ReadWriteOnce" ] - resources: - requests: - storage: 3Gi - - metadata: - name: cassandra-commitlog - annotations: - volume.beta.kubernetes.io/storage-class: fast - spec: - accessModes: [ "ReadWriteOnce" ] - resources: - requests: - storage: 2Gi \ No newline at end of file diff --git a/docker/k8s/common.yaml b/docker/k8s/common.yaml deleted file mode 100644 index 75a938a0ff..0000000000 --- a/docker/k8s/common.yaml +++ /dev/null @@ -1,33 +0,0 @@ -# -# 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. -# - ---- -apiVersion: storage.k8s.io/v1beta1 -kind: StorageClass -metadata: - name: slow -provisioner: kubernetes.io/gce-pd -parameters: - type: pd-standard ---- -apiVersion: storage.k8s.io/v1beta1 -kind: StorageClass -metadata: - name: fast -provisioner: kubernetes.io/gce-pd -parameters: - type: pd-ssd ---- \ No newline at end of file diff --git a/docker/k8s/redis.yaml b/docker/k8s/redis.yaml deleted file mode 100644 index 3af810e1e3..0000000000 --- a/docker/k8s/redis.yaml +++ /dev/null @@ -1,93 +0,0 @@ -# -# 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. -# - ---- -apiVersion: v1 -kind: Service -metadata: - labels: - name: redis-service - name: redis-service -spec: - ports: - - name: redis-service - protocol: TCP - port: 6379 - targetPort: 6379 - selector: - app: redis ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: redis-conf -data: - redis.conf: | - appendonly yes - protected-mode no - bind 0.0.0.0 - port 6379 - dir /var/lib/redis ---- -apiVersion: apps/v1beta1 -kind: StatefulSet -metadata: - name: redis -spec: - serviceName: redis-service - replicas: 1 - template: - metadata: - labels: - app: redis - spec: - terminationGracePeriodSeconds: 10 - containers: - - name: redis - image: redis:4.0.9 - command: - - redis-server - args: - - /etc/redis/redis.conf - resources: - requests: - cpu: 100m - memory: 100Mi - ports: - - containerPort: 6379 - name: redis - volumeMounts: - - name: redis-data - mountPath: /var/lib/redis - - name: redis-conf - mountPath: /etc/redis - volumes: - - name: redis-conf - configMap: - name: redis-conf - items: - - key: redis.conf - path: redis.conf - volumeClaimTemplates: - - metadata: - name: redis-data - annotations: - volume.beta.kubernetes.io/storage-class: fast - spec: - accessModes: [ "ReadWriteOnce" ] - resources: - requests: - storage: 1Gi \ No newline at end of file diff --git a/docker/k8s/tb.yaml b/docker/k8s/tb.yaml deleted file mode 100644 index 741bbe0f26..0000000000 --- a/docker/k8s/tb.yaml +++ /dev/null @@ -1,156 +0,0 @@ -# -# 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. -# - ---- -apiVersion: v1 -kind: Service -metadata: - name: tb-service - labels: - app: tb-service -spec: - ports: - - port: 8080 - name: ui - - port: 1883 - name: mqtt - - port: 5683 - name: coap - selector: - app: tb - type: LoadBalancer ---- -apiVersion: policy/v1beta1 -kind: PodDisruptionBudget -metadata: - name: tb-budget -spec: - selector: - matchLabels: - app: tb - minAvailable: 3 ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: tb-config -data: - zookeeper.enabled: "true" - zookeeper.url: "zk-headless" - cassandra.url: "cassandra-headless:9042" - cassandra.host: "cassandra-headless" - cassandra.port: "9042" - database.type: "cassandra" - cache.type: "redis" - redis.host: "redis-service" ---- -apiVersion: apps/v1beta1 -kind: StatefulSet -metadata: - name: tb -spec: - serviceName: "tb-service" - replicas: 3 - template: - metadata: - labels: - app: tb - spec: - nodeSelector: - machinetype: tb - affinity: - podAntiAffinity: - requiredDuringSchedulingIgnoredDuringExecution: - - labelSelector: - matchExpressions: - - key: "app" - operator: In - values: - - tb-service - topologyKey: "kubernetes.io/hostname" - containers: - - name: tb - imagePullPolicy: Always - image: thingsboard/application:2.1.0 - ports: - - containerPort: 8080 - name: ui - - containerPort: 1883 - name: mqtt - - containerPort: 5683 - name: coap - - containerPort: 9001 - name: rpc - env: - - name: ZOOKEEPER_ENABLED - valueFrom: - configMapKeyRef: - name: tb-config - key: zookeeper.enabled - - name: ZOOKEEPER_URL - valueFrom: - configMapKeyRef: - name: tb-config - key: zookeeper.url - - name : CASSANDRA_HOST - valueFrom: - configMapKeyRef: - name: tb-config - key: cassandra.host - - name : CASSANDRA_PORT - valueFrom: - configMapKeyRef: - name: tb-config - key: cassandra.port - - name : CASSANDRA_URL - valueFrom: - configMapKeyRef: - name: tb-config - key: cassandra.url - - name: DATABASE_ENTITIES_TYPE - valueFrom: - configMapKeyRef: - name: tb-config - key: database.type - - name: DATABASE_TS_TYPE - valueFrom: - configMapKeyRef: - name: tb-config - key: database.type - - name : RPC_HOST - valueFrom: - fieldRef: - fieldPath: status.podIP - - name: CACHE_TYPE - valueFrom: - configMapKeyRef: - name: tb-config - key: cache.type - - name: REDIS_HOST - valueFrom: - configMapKeyRef: - name: tb-config - key: redis.host - command: - - sh - - -c - - /run-application.sh - livenessProbe: - httpGet: - path: /login - port: ui-port - initialDelaySeconds: 120 - timeoutSeconds: 10 \ No newline at end of file diff --git a/docker/k8s/zookeeper.yaml b/docker/k8s/zookeeper.yaml deleted file mode 100644 index ae33ea2efa..0000000000 --- a/docker/k8s/zookeeper.yaml +++ /dev/null @@ -1,190 +0,0 @@ -# -# 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. -# - -apiVersion: v1 -kind: Service -metadata: - name: zk-headless - labels: - app: zk-headless -spec: - ports: - - port: 2888 - name: server - - port: 3888 - name: leader-election - clusterIP: None - selector: - app: zk ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: zk-config -data: - ensemble: "zk-0;zk-1;zk-2" - replicas: "3" - jvm.heap: "500m" - tick: "2000" - init: "10" - sync: "5" - client.cnxns: "60" - snap.retain: "3" - purge.interval: "1" - client.port: "2181" - server.port: "2888" - election.port: "3888" ---- -apiVersion: policy/v1beta1 -kind: PodDisruptionBudget -metadata: - name: zk-budget -spec: - selector: - matchLabels: - app: zk - minAvailable: 3 ---- -apiVersion: apps/v1beta1 -kind: StatefulSet -metadata: - name: zk -spec: - serviceName: zk-headless - replicas: 3 - template: - metadata: - labels: - app: zk - annotations: - pod.alpha.kubernetes.io/initialized: "true" - spec: - nodeSelector: - machinetype: other - affinity: - podAntiAffinity: - requiredDuringSchedulingIgnoredDuringExecution: - - labelSelector: - matchExpressions: - - key: "app" - operator: In - values: - - zk-headless - topologyKey: "kubernetes.io/hostname" - containers: - - name: zk - imagePullPolicy: Always - image: thingsboard/zk:2.1.0 - ports: - - containerPort: 2181 - name: client - - containerPort: 2888 - name: server - - containerPort: 3888 - name: leader-election - env: - - name : ZK_ENSEMBLE - valueFrom: - configMapKeyRef: - name: zk-config - key: ensemble - - name : ZK_REPLICAS - valueFrom: - configMapKeyRef: - name: zk-config - key: replicas - - name : ZK_HEAP_SIZE - valueFrom: - configMapKeyRef: - name: zk-config - key: jvm.heap - - name : ZK_TICK_TIME - valueFrom: - configMapKeyRef: - name: zk-config - key: tick - - name : ZK_INIT_LIMIT - valueFrom: - configMapKeyRef: - name: zk-config - key: init - - name : ZK_SYNC_LIMIT - valueFrom: - configMapKeyRef: - name: zk-config - key: tick - - name : ZK_MAX_CLIENT_CNXNS - valueFrom: - configMapKeyRef: - name: zk-config - key: client.cnxns - - name: ZK_SNAP_RETAIN_COUNT - valueFrom: - configMapKeyRef: - name: zk-config - key: snap.retain - - name: ZK_PURGE_INTERVAL - valueFrom: - configMapKeyRef: - name: zk-config - key: purge.interval - - name: ZK_CLIENT_PORT - valueFrom: - configMapKeyRef: - name: zk-config - key: client.port - - name: ZK_SERVER_PORT - valueFrom: - configMapKeyRef: - name: zk-config - key: server.port - - name: ZK_ELECTION_PORT - valueFrom: - configMapKeyRef: - name: zk-config - key: election.port - command: - - sh - - -c - - zk-gen-config.sh && zkServer.sh start-foreground - readinessProbe: - exec: - command: - - "zk-ok.sh" - initialDelaySeconds: 15 - timeoutSeconds: 5 - livenessProbe: - exec: - command: - - "zk-ok.sh" - initialDelaySeconds: 15 - timeoutSeconds: 5 - volumeMounts: - - name: zkdatadir - mountPath: /var/lib/zookeeper - securityContext: - runAsUser: 1000 - fsGroup: 1000 - volumeClaimTemplates: - - metadata: - name: zkdatadir - annotations: - volume.beta.kubernetes.io/storage-class: slow - spec: - accessModes: [ "ReadWriteOnce" ] - resources: - requests: - storage: 1Gi \ No newline at end of file diff --git a/msa/docker/tb-coap-transport.env b/docker/tb-coap-transport.env similarity index 100% rename from msa/docker/tb-coap-transport.env rename to docker/tb-coap-transport.env diff --git a/msa/docker/tb-http-transport.env b/docker/tb-http-transport.env similarity index 100% rename from msa/docker/tb-http-transport.env rename to docker/tb-http-transport.env diff --git a/msa/docker/tb-js-executor.env b/docker/tb-js-executor.env similarity index 100% rename from msa/docker/tb-js-executor.env rename to docker/tb-js-executor.env diff --git a/msa/docker/tb-mqtt-transport.env b/docker/tb-mqtt-transport.env similarity index 100% rename from msa/docker/tb-mqtt-transport.env rename to docker/tb-mqtt-transport.env diff --git a/docker/tb-node.env b/docker/tb-node.env new file mode 100644 index 0000000000..311428adc6 --- /dev/null +++ b/docker/tb-node.env @@ -0,0 +1,3 @@ +# ThingsBoard server configuration + +TRANSPORT_TYPE=remote diff --git a/msa/docker/tb-node/conf/logback.xml b/docker/tb-node/conf/logback.xml similarity index 100% rename from msa/docker/tb-node/conf/logback.xml rename to docker/tb-node/conf/logback.xml diff --git a/msa/docker/tb-node/conf/thingsboard.conf b/docker/tb-node/conf/thingsboard.conf similarity index 100% rename from msa/docker/tb-node/conf/thingsboard.conf rename to docker/tb-node/conf/thingsboard.conf diff --git a/msa/docker/tb-web-ui.env b/docker/tb-web-ui.env similarity index 100% rename from msa/docker/tb-web-ui.env rename to docker/tb-web-ui.env diff --git a/docker/tb.env b/docker/tb.env deleted file mode 100644 index bc92de5c8b..0000000000 --- a/docker/tb.env +++ /dev/null @@ -1,26 +0,0 @@ -#Thingsboard server configuration -MQTT_BIND_ADDRESS=0.0.0.0 -MQTT_BIND_PORT=1883 -COAP_BIND_ADDRESS=0.0.0.0 -COAP_BIND_PORT=5683 - -# zk config -ZOOKEEPER_URL=zk:2181 - -# type of database to use: sql[DEFAULT] or cassandra -DATABASE_TS_TYPE=sql -DATABASE_ENTITIES_TYPE=sql - -# cassandra db config -CASSANDRA_URL=cassandra:9042 -CASSANDRA_HOST=cassandra -CASSANDRA_PORT=9042 - -# postgres db config -POSTGRES_HOST=postgres -POSTGRES_PORT=5432 -# 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 diff --git a/docker/tb/Dockerfile b/docker/tb/Dockerfile deleted file mode 100644 index 24281f9f3e..0000000000 --- a/docker/tb/Dockerfile +++ /dev/null @@ -1,26 +0,0 @@ -# -# 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. -# - -FROM openjdk:8-jre - -ADD run-application.sh /run-application.sh -ADD thingsboard.deb /thingsboard.deb - -RUN apt-get update \ - && apt-get install --no-install-recommends -y nmap \ - && apt-get clean \ - && rm -r /var/lib/apt/lists/* \ - && chmod +x /run-application.sh diff --git a/docker/tb/Makefile b/docker/tb/Makefile deleted file mode 100644 index 96803abf58..0000000000 --- a/docker/tb/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -VERSION=2.1.0 -PROJECT=thingsboard -APP=application - -build: - cp ../../application/target/thingsboard.deb . - docker build --pull -t ${PROJECT}/${APP}:${VERSION} -t ${PROJECT}/${APP}:latest . - rm thingsboard.deb - -push: build - docker push ${PROJECT}/${APP}:${VERSION} - docker push ${PROJECT}/${APP}:latest diff --git a/docker/tb/run-application.sh b/docker/tb/run-application.sh deleted file mode 100755 index e6b59f9aee..0000000000 --- a/docker/tb/run-application.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/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. -# - - -dpkg -i /thingsboard.deb - -# Copying env variables into conf files -printenv | awk -F "=" '{print "export " $1 "='\''" $2 "'\''"}' >> /usr/share/thingsboard/conf/thingsboard.conf - -cat /usr/share/thingsboard/conf/thingsboard.conf - -if [ "$DATABASE_ENTITIES_TYPE" == "cassandra" ]; then - until nmap $CASSANDRA_HOST -p $CASSANDRA_PORT | grep "$CASSANDRA_PORT/tcp open\|filtered" - do - echo "Wait for cassandra db to start..." - sleep 10 - done -fi - -if [ "$DATABASE_ENTITIES_TYPE" == "sql" ]; then - if [ "$SPRING_DRIVER_CLASS_NAME" == "org.postgresql.Driver" ]; then - until nmap $POSTGRES_HOST -p $POSTGRES_PORT | grep "$POSTGRES_PORT/tcp open" - do - echo "Waiting for postgres db to start..." - sleep 10 - done - fi -fi - -if [ "$ADD_SCHEMA_AND_SYSTEM_DATA" == "true" ]; then - echo "Creating 'Thingsboard' schema and system data..." - if [ "$ADD_DEMO_DATA" == "true" ]; then - echo "plus demo data..." - /usr/share/thingsboard/bin/install/install.sh --loadDemo - elif [ "$ADD_DEMO_DATA" == "false" ]; then - /usr/share/thingsboard/bin/install/install.sh - fi -fi - -echo "Starting 'Thingsboard' service..." -service thingsboard start - -# Wait until log file is created -sleep 10 -tail -f /var/log/thingsboard/thingsboard.log diff --git a/docker/zookeeper/Dockerfile b/docker/zookeeper/Dockerfile deleted file mode 100644 index 38f13fca14..0000000000 --- a/docker/zookeeper/Dockerfile +++ /dev/null @@ -1,71 +0,0 @@ -# -# 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. -# - -FROM ubuntu:16.04 -ENV ZK_USER=zookeeper \ -ZK_DATA_DIR=/var/lib/zookeeper/data \ -ZK_DATA_LOG_DIR=/var/lib/zookeeper/log \ -ZK_LOG_DIR=/var/log/zookeeper \ -JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 - -ARG GPG_KEY=C823E3E5B12AF29C67F81976F5CECB3CB5E9BD2D -ARG ZK_DIST=zookeeper-3.4.10 -RUN set -x \ - && apt-get update \ - && apt-get install -y openjdk-8-jre-headless wget netcat-openbsd \ - && wget -q "http://www.apache.org/dist/zookeeper/$ZK_DIST/$ZK_DIST.tar.gz" \ - && wget -q "http://www.apache.org/dist/zookeeper/$ZK_DIST/$ZK_DIST.tar.gz.asc" \ - && export GNUPGHOME="$(mktemp -d)" \ - && gpg --keyserver ha.pool.sks-keyservers.net --recv-key "$GPG_KEY" \ - && gpg --batch --verify "$ZK_DIST.tar.gz.asc" "$ZK_DIST.tar.gz" \ - && tar -xzf "$ZK_DIST.tar.gz" -C /opt \ - && rm -r "$GNUPGHOME" "$ZK_DIST.tar.gz" "$ZK_DIST.tar.gz.asc" \ - && ln -s /opt/$ZK_DIST /opt/zookeeper \ - && rm -rf /opt/zookeeper/CHANGES.txt \ - /opt/zookeeper/README.txt \ - /opt/zookeeper/NOTICE.txt \ - /opt/zookeeper/CHANGES.txt \ - /opt/zookeeper/README_packaging.txt \ - /opt/zookeeper/build.xml \ - /opt/zookeeper/config \ - /opt/zookeeper/contrib \ - /opt/zookeeper/dist-maven \ - /opt/zookeeper/docs \ - /opt/zookeeper/ivy.xml \ - /opt/zookeeper/ivysettings.xml \ - /opt/zookeeper/recipes \ - /opt/zookeeper/src \ - /opt/zookeeper/$ZK_DIST.jar.asc \ - /opt/zookeeper/$ZK_DIST.jar.md5 \ - /opt/zookeeper/$ZK_DIST.jar.sha1 \ - && apt-get autoremove -y wget \ - && rm -rf /var/lib/apt/lists/* - -#Copy configuration generator script to bin -COPY zk-gen-config.sh zk-ok.sh /opt/zookeeper/bin/ - -# Create a user for the zookeeper process and configure file system ownership -# for nessecary directories and symlink the distribution as a user executable -RUN set -x \ - && useradd $ZK_USER \ - && [ `id -u $ZK_USER` -eq 1000 ] \ - && [ `id -g $ZK_USER` -eq 1000 ] \ - && mkdir -p $ZK_DATA_DIR $ZK_DATA_LOG_DIR $ZK_LOG_DIR /usr/share/zookeeper /tmp/zookeeper /usr/etc/ \ - && chown -R "$ZK_USER:$ZK_USER" /opt/$ZK_DIST $ZK_DATA_DIR $ZK_LOG_DIR $ZK_DATA_LOG_DIR /tmp/zookeeper \ - && ln -s /opt/zookeeper/conf/ /usr/etc/zookeeper \ - && ln -s /opt/zookeeper/bin/* /usr/bin \ - && ln -s /opt/zookeeper/$ZK_DIST.jar /usr/share/zookeeper/ \ - && ln -s /opt/zookeeper/lib/* /usr/share/zookeeper diff --git a/docker/zookeeper/Makefile b/docker/zookeeper/Makefile deleted file mode 100644 index 5c58a74cf2..0000000000 --- a/docker/zookeeper/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -VERSION=2.1.0 -PROJECT=thingsboard -APP=zk - -build: - docker build --pull -t ${PROJECT}/${APP}:${VERSION} -t ${PROJECT}/${APP}:latest . - -push: build - docker push ${PROJECT}/${APP}:${VERSION} - docker push ${PROJECT}/${APP}:latest diff --git a/docker/zookeeper/zk-gen-config.sh b/docker/zookeeper/zk-gen-config.sh deleted file mode 100755 index 5516f570c1..0000000000 --- a/docker/zookeeper/zk-gen-config.sh +++ /dev/null @@ -1,153 +0,0 @@ -#!/usr/bin/env 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. -# - -ZK_USER=${ZK_USER:-"zookeeper"} -ZK_LOG_LEVEL=${ZK_LOG_LEVEL:-"INFO"} -ZK_DATA_DIR=${ZK_DATA_DIR:-"/var/lib/zookeeper/data"} -ZK_DATA_LOG_DIR=${ZK_DATA_LOG_DIR:-"/var/lib/zookeeper/log"} -ZK_LOG_DIR=${ZK_LOG_DIR:-"var/log/zookeeper"} -ZK_CONF_DIR=${ZK_CONF_DIR:-"/opt/zookeeper/conf"} -ZK_CLIENT_PORT=${ZK_CLIENT_PORT:-2181} -ZK_SERVER_PORT=${ZK_SERVER_PORT:-2888} -ZK_ELECTION_PORT=${ZK_ELECTION_PORT:-3888} -ZK_TICK_TIME=${ZK_TICK_TIME:-2000} -ZK_INIT_LIMIT=${ZK_INIT_LIMIT:-10} -ZK_SYNC_LIMIT=${ZK_SYNC_LIMIT:-5} -ZK_HEAP_SIZE=${ZK_HEAP_SIZE:-2G} -ZK_MAX_CLIENT_CNXNS=${ZK_MAX_CLIENT_CNXNS:-60} -ZK_MIN_SESSION_TIMEOUT=${ZK_MIN_SESSION_TIMEOUT:- $((ZK_TICK_TIME*2))} -ZK_MAX_SESSION_TIMEOUT=${ZK_MAX_SESSION_TIMEOUT:- $((ZK_TICK_TIME*20))} -ZK_SNAP_RETAIN_COUNT=${ZK_SNAP_RETAIN_COUNT:-3} -ZK_PURGE_INTERVAL=${ZK_PURGE_INTERVAL:-0} -ID_FILE="$ZK_DATA_DIR/myid" -ZK_CONFIG_FILE="$ZK_CONF_DIR/zoo.cfg" -LOGGER_PROPS_FILE="$ZK_CONF_DIR/log4j.properties" -JAVA_ENV_FILE="$ZK_CONF_DIR/java.env" -HOST=`hostname -s` -DOMAIN=`hostname -d` - -function print_servers() { - for (( i=1; i<=$ZK_REPLICAS; i++ )) - do - echo "server.$i=$NAME-$((i-1)).$DOMAIN:$ZK_SERVER_PORT:$ZK_ELECTION_PORT" - done -} - -function validate_env() { - echo "Validating environment" - if [ -z $ZK_REPLICAS ]; then - echo "ZK_REPLICAS is a mandatory environment variable" - exit 1 - fi - - if [[ $HOST =~ (.*)-([0-9]+)$ ]]; then - NAME=${BASH_REMATCH[1]} - ORD=${BASH_REMATCH[2]} - else - echo "Failed to extract ordinal from hostname $HOST" - exit 1 - fi - MY_ID=$((ORD+1)) - echo "ZK_REPLICAS=$ZK_REPLICAS" - echo "MY_ID=$MY_ID" - echo "ZK_LOG_LEVEL=$ZK_LOG_LEVEL" - echo "ZK_DATA_DIR=$ZK_DATA_DIR" - echo "ZK_DATA_LOG_DIR=$ZK_DATA_LOG_DIR" - echo "ZK_LOG_DIR=$ZK_LOG_DIR" - echo "ZK_CLIENT_PORT=$ZK_CLIENT_PORT" - echo "ZK_SERVER_PORT=$ZK_SERVER_PORT" - echo "ZK_ELECTION_PORT=$ZK_ELECTION_PORT" - echo "ZK_TICK_TIME=$ZK_TICK_TIME" - echo "ZK_INIT_LIMIT=$ZK_INIT_LIMIT" - echo "ZK_SYNC_LIMIT=$ZK_SYNC_LIMIT" - echo "ZK_MAX_CLIENT_CNXNS=$ZK_MAX_CLIENT_CNXNS" - echo "ZK_MIN_SESSION_TIMEOUT=$ZK_MIN_SESSION_TIMEOUT" - echo "ZK_MAX_SESSION_TIMEOUT=$ZK_MAX_SESSION_TIMEOUT" - echo "ZK_HEAP_SIZE=$ZK_HEAP_SIZE" - echo "ZK_SNAP_RETAIN_COUNT=$ZK_SNAP_RETAIN_COUNT" - echo "ZK_PURGE_INTERVAL=$ZK_PURGE_INTERVAL" - echo "ENSEMBLE" - print_servers - echo "Environment validation successful" -} - -function create_config() { - rm -f $ZK_CONFIG_FILE - echo "Creating ZooKeeper configuration" - echo "#This file was autogenerated by zk DO NOT EDIT" >> $ZK_CONFIG_FILE - echo "clientPort=$ZK_CLIENT_PORT" >> $ZK_CONFIG_FILE - echo "dataDir=$ZK_DATA_DIR" >> $ZK_CONFIG_FILE - echo "dataLogDir=$ZK_DATA_LOG_DIR" >> $ZK_CONFIG_FILE - echo "tickTime=$ZK_TICK_TIME" >> $ZK_CONFIG_FILE - echo "initLimit=$ZK_INIT_LIMIT" >> $ZK_CONFIG_FILE - echo "syncLimit=$ZK_SYNC_LIMIT" >> $ZK_CONFIG_FILE - echo "maxClientCnxns=$ZK_MAX_CLIENT_CNXNS" >> $ZK_CONFIG_FILE - echo "minSessionTimeout=$ZK_MIN_SESSION_TIMEOUT" >> $ZK_CONFIG_FILE - echo "maxSessionTimeout=$ZK_MAX_SESSION_TIMEOUT" >> $ZK_CONFIG_FILE - echo "autopurge.snapRetainCount=$ZK_SNAP_RETAIN_COUNT" >> $ZK_CONFIG_FILE - echo "autopurge.purgeInteval=$ZK_PURGE_INTERVAL" >> $ZK_CONFIG_FILE - - if [ $ZK_REPLICAS -gt 1 ]; then - print_servers >> $ZK_CONFIG_FILE - fi - echo "Wrote ZooKeeper configuration file to $ZK_CONFIG_FILE" -} - -function create_data_dirs() { - echo "Creating ZooKeeper data directories and setting permissions" - if [ ! -d $ZK_DATA_DIR ]; then - mkdir -p $ZK_DATA_DIR - chown -R $ZK_USER:$ZK_USER $ZK_DATA_DIR - fi - - if [ ! -d $ZK_DATA_LOG_DIR ]; then - mkdir -p $ZK_DATA_LOG_DIR - chown -R $ZK_USER:$ZK_USER $ZK_DATA_LOG_DIR - fi - - if [ ! -d $ZK_LOG_DIR ]; then - mkdir -p $ZK_LOG_DIR - chown -R $ZK_USER:$ZK_USER $ZK_LOG_DIR - fi - if [ ! -f $ID_FILE ]; then - echo $MY_ID >> $ID_FILE - fi - echo "Created ZooKeeper data directories and set permissions in $ZK_DATA_DIR" -} - -function create_log_props () { - rm -f $LOGGER_PROPS_FILE - echo "Creating ZooKeeper log4j configuration" - echo "zookeeper.root.logger=CONSOLE" >> $LOGGER_PROPS_FILE - echo "zookeeper.console.threshold="$ZK_LOG_LEVEL >> $LOGGER_PROPS_FILE - echo "log4j.rootLogger=\${zookeeper.root.logger}" >> $LOGGER_PROPS_FILE - echo "log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender" >> $LOGGER_PROPS_FILE - echo "log4j.appender.CONSOLE.Threshold=\${zookeeper.console.threshold}" >> $LOGGER_PROPS_FILE - echo "log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout" >> $LOGGER_PROPS_FILE - echo "log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}@%L] - %m%n" >> $LOGGER_PROPS_FILE - echo "Wrote log4j configuration to $LOGGER_PROPS_FILE" -} - -function create_java_env() { - rm -f $JAVA_ENV_FILE - echo "Creating JVM configuration file" - echo "ZOO_LOG_DIR=$ZK_LOG_DIR" >> $JAVA_ENV_FILE - echo "JVMFLAGS=\"-Xmx$ZK_HEAP_SIZE -Xms$ZK_HEAP_SIZE\"" >> $JAVA_ENV_FILE - echo "Wrote JVM configuration to $JAVA_ENV_FILE" -} - -validate_env && create_config && create_log_props && create_data_dirs && create_java_env diff --git a/docker/zookeeper/zk-ok.sh b/docker/zookeeper/zk-ok.sh deleted file mode 100755 index 9f45db259d..0000000000 --- a/docker/zookeeper/zk-ok.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env 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. -# - -# zk-ok.sh uses the ruok ZooKeeper four letter work to determine if the instance -# is health. The $? variable will be set to 0 if server responds that it is -# healthy, or 1 if the server fails to respond. - -ZK_CLIENT_PORT=${ZK_CLIENT_PORT:-2181} -OK=$(echo ruok | nc 127.0.0.1 $ZK_CLIENT_PORT) -if [ "$OK" == "imok" ]; then - exit 0 -else - exit 1 -fi diff --git a/msa/docker/.env b/msa/docker/.env deleted file mode 100644 index afcd91ced5..0000000000 --- a/msa/docker/.env +++ /dev/null @@ -1,13 +0,0 @@ - -DOCKER_REPO=local-maven-build - -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 - -TB_VERSION=2.2.0-SNAPSHOT - -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 diff --git a/msa/docker/docker-compose.yml b/msa/docker/docker-compose.yml deleted file mode 100644 index 5410533822..0000000000 --- a/msa/docker/docker-compose.yml +++ /dev/null @@ -1,177 +0,0 @@ -# -# 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: - zookeeper: - restart: always - image: "wurstmeister/zookeeper" - ports: - - "2181" - kafka: - restart: always - image: "wurstmeister/kafka" - ports: - - "9092:9092" - environment: - KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 - KAFKA_LISTENERS: INSIDE://:9093,OUTSIDE://:9092 - KAFKA_ADVERTISED_LISTENERS: INSIDE://:9093,OUTSIDE://kafka:9092 - KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INSIDE:PLAINTEXT,OUTSIDE:PLAINTEXT - KAFKA_INTER_BROKER_LISTENER_NAME: INSIDE - KAFKA_CREATE_TOPICS: "${KAFKA_TOPICS}" - KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'false' - KAFKA_LOG_RETENTION_BYTES: 1073741824 - KAFKA_LOG_SEGMENT_BYTES: 268435456 - KAFKA_LOG_RETENTION_MS: 300000 - KAFKA_LOG_CLEANUP_POLICY: delete - depends_on: - - zookeeper - tb-js-executor: - restart: always - image: "${DOCKER_REPO}/${JS_EXECUTOR_DOCKER_NAME}:${TB_VERSION}" - scale: 20 - environment: - TB_KAFKA_SERVERS: kafka:9092 - env_file: - - tb-js-executor.env - depends_on: - - kafka - tb: - restart: always - image: "${DOCKER_REPO}/${TB_NODE_DOCKER_NAME}:${TB_VERSION}" - ports: - - "8080" - logging: - driver: "json-file" - options: - max-size: "200m" - max-file: "30" - env_file: - - tb-node.env - environment: - ZOOKEEPER_URL: zk:2181 - TB_KAFKA_SERVERS: kafka:9092 - JS_EVALUATOR: remote - volumes: - - ./tb-node/db:/usr/share/thingsboard/data/db - - ./tb-node/conf:/config - - ./tb-node/log:/var/log/thingsboard - depends_on: - - kafka - tb-mqtt-transport1: - restart: always - image: "${DOCKER_REPO}/${MQTT_TRANSPORT_DOCKER_NAME}:${TB_VERSION}" - ports: - - "1883" - environment: - TB_KAFKA_SERVERS: kafka:9092 - env_file: - - tb-mqtt-transport.env - depends_on: - - kafka - tb-mqtt-transport2: - restart: always - image: "${DOCKER_REPO}/${MQTT_TRANSPORT_DOCKER_NAME}:${TB_VERSION}" - ports: - - "1883" - environment: - TB_KAFKA_SERVERS: kafka:9092 - env_file: - - tb-mqtt-transport.env - depends_on: - - kafka - tb-http-transport1: - restart: always - image: "${DOCKER_REPO}/${HTTP_TRANSPORT_DOCKER_NAME}:${TB_VERSION}" - ports: - - "8081" - environment: - TB_KAFKA_SERVERS: kafka:9092 - env_file: - - tb-http-transport.env - depends_on: - - kafka - tb-http-transport2: - restart: always - image: "${DOCKER_REPO}/${HTTP_TRANSPORT_DOCKER_NAME}:${TB_VERSION}" - ports: - - "8081" - environment: - TB_KAFKA_SERVERS: kafka:9092 - env_file: - - tb-http-transport.env - depends_on: - - kafka - tb-coap-transport: - restart: always - image: "${DOCKER_REPO}/${COAP_TRANSPORT_DOCKER_NAME}:${TB_VERSION}" - ports: - - "5683:5683/udp" - environment: - TB_KAFKA_SERVERS: kafka:9092 - env_file: - - tb-coap-transport.env - depends_on: - - kafka - tb-web-ui1: - restart: always - image: "${DOCKER_REPO}/${WEB_UI_DOCKER_NAME}:${TB_VERSION}" - ports: - - "8080" - environment: - TB_HOST: tb - TB_PORT: 8080 - env_file: - - tb-web-ui.env - tb-web-ui2: - restart: always - image: "${DOCKER_REPO}/${WEB_UI_DOCKER_NAME}:${TB_VERSION}" - ports: - - "8080" - environment: - TB_HOST: tb - TB_PORT: 8080 - env_file: - - tb-web-ui.env - web: - restart: always - container_name: haproxy-certbot - image: nmarus/haproxy-certbot - volumes: - - ./haproxy/config:/config - - ./haproxy/letsencrypt:/etc/letsencrypt - - ./haproxy/certs.d:/usr/local/etc/haproxy/certs.d - ports: - - "80:80" - - "443:443" - - "1883:1883" - - "9999:9999" - cap_add: - - NET_ADMIN - environment: - HTTP_PORT: 80 - HTTPS_PORT: 443 - MQTT_PORT: 1883 - links: - - tb-web-ui1 - - tb-web-ui2 - - tb-mqtt-transport1 - - tb-mqtt-transport2 - - tb-http-transport1 - - tb-http-transport2 diff --git a/msa/docker/tb-node.env b/msa/docker/tb-node.env deleted file mode 100644 index abeccb12eb..0000000000 --- a/msa/docker/tb-node.env +++ /dev/null @@ -1,22 +0,0 @@ -# ThingsBoard server configuration - -TRANSPORT_TYPE=remote - -# type of database to use: sql[DEFAULT] or cassandra -DATABASE_TS_TYPE=sql -DATABASE_ENTITIES_TYPE=sql -SQL_DATA_FOLDER=/usr/share/thingsboard/data/db - -# cassandra db config -CASSANDRA_URL=cassandra:9042 -CASSANDRA_HOST=cassandra -CASSANDRA_PORT=9042 - -# postgres db config -POSTGRES_HOST=postgres -POSTGRES_PORT=5432 -# 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 diff --git a/msa/js-executor/pom.xml b/msa/js-executor/pom.xml index 6f11df1452..e673a5389c 100644 --- a/msa/js-executor/pom.xml +++ b/msa/js-executor/pom.xml @@ -287,16 +287,27 @@ build + + ${dockerfile.skip} + ${docker.repo}/${docker.name} + true + false + ${project.build.directory} + + + + tag-docker-image + pre-integration-test + + tag + + + ${dockerfile.skip} + ${docker.repo}/${docker.name} + ${project.version} + - - ${dockerfile.skip} - ${docker.repo}/${docker.name} - ${project.version} - true - false - ${project.build.directory} - @@ -334,6 +345,46 @@ + + push-docker-image + + + push-docker-image + + + + + + com.spotify + dockerfile-maven-plugin + + + push-latest-docker-image + pre-integration-test + + push + + + latest + ${docker.repo}/${docker.name} + + + + push-version-docker-image + pre-integration-test + + push + + + ${project.version} + ${docker.repo}/${docker.name} + + + + + + + diff --git a/msa/pom.xml b/msa/pom.xml index 59f954a1ed..5fd2212e1e 100644 --- a/msa/pom.xml +++ b/msa/pom.xml @@ -32,11 +32,12 @@ ${basedir}/.. - local-maven-build + thingsboard true + tb js-executor web-ui tb-node diff --git a/msa/tb-node/pom.xml b/msa/tb-node/pom.xml index 18a81f3970..fc62189e62 100644 --- a/msa/tb-node/pom.xml +++ b/msa/tb-node/pom.xml @@ -111,19 +111,72 @@ build + + ${dockerfile.skip} + ${docker.repo}/${docker.name} + true + false + ${project.build.directory} + + + + tag-docker-image + pre-integration-test + + tag + + + ${dockerfile.skip} + ${docker.repo}/${docker.name} + ${project.version} + - - ${dockerfile.skip} - ${docker.repo}/${docker.name} - ${project.version} - true - false - ${project.build.directory} - + + + push-docker-image + + + push-docker-image + + + + + + com.spotify + dockerfile-maven-plugin + + + push-latest-docker-image + pre-integration-test + + push + + + latest + ${docker.repo}/${docker.name} + + + + push-version-docker-image + pre-integration-test + + push + + + ${project.version} + ${docker.repo}/${docker.name} + + + + + + + + jenkins diff --git a/msa/tb/README.md b/msa/tb/README.md new file mode 100644 index 0000000000..228aaa112a --- /dev/null +++ b/msa/tb/README.md @@ -0,0 +1,68 @@ +# ThingsBoard single docker images + +This project provides the build for the ThingsBoard single docker images. + +* `thingsboard/tb` - single instance of ThingsBoard with embedded HSQLDB database. +* `thingsboard/tb-postgres` - single instance of ThingsBoard with PostgreSQL database. +* `thingsboard/tb-cassandra` - single instance of ThingsBoard with Cassandra database. + +## Running + +Execute the following command to run this docker directly: + +` +$ docker run -it -p 9090:9090 -p 1883:1883 -p 5683:5683/udp -v ~/.mytb-data:/data --name mytb thingsboard/tb +` + +Where: + +- `docker run` - run this container +- `-it` - attach a terminal session with current ThingsBoard process output +- `-p 9090:9090` - connect local port 9090 to exposed internal HTTP port 9090 +- `-p 1883:1883` - connect local port 1883 to exposed internal MQTT port 1883 +- `-p 5683:5683` - connect local port 5683 to exposed internal COAP port 5683 +- `-v ~/.mytb-data:/data` - mounts the host's dir `~/.mytb-data` to ThingsBoard DataBase data directory +- `--name mytb` - friendly local name of this machine +- `thingsboard/tb` - docker image + +After executing this command you can open `http://{yor-host-ip}:9090` in you browser. You should see ThingsBoard login page. +Use the following default credentials: + +- **Systen Administrator**: sysadmin@thingsboard.org / sysadmin +- **Tenant Administrator**: tenant@thingsboard.org / tenant +- **Customer User**: customer@thingsboard.org / customer + +You can always change passwords for each account in account profile page. + +You can detach from session terminal with `Ctrl-p` `Ctrl-q` - the container will keep running in the background. + +To reattach to the terminal (to see ThingsBoard logs) run: + +` +$ docker attach mytb +` + +To stop the container: + +` +$ docker stop mytb +` + +To start the container: + +` +$ docker start mytb +` + +## Upgrading + +In order to update to the latest image, execute the following commands: + +` +$ docker pull thingsboard/tb +$ docker stop mytb +$ docker run -it -v ~/.mytb-data:/data --rm thingsboard/tb upgrade-tb.sh +$ docker start mytb +` + +**NOTE**: replace host's directory `~/.mytb-data` with directory used during container creation. diff --git a/msa/tb/docker-cassandra/Dockerfile b/msa/tb/docker-cassandra/Dockerfile new file mode 100644 index 0000000000..175ad9abe1 --- /dev/null +++ b/msa/tb/docker-cassandra/Dockerfile @@ -0,0 +1,59 @@ +# +# 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. +# + +FROM openjdk:8-jre + +RUN apt-get update +RUN apt-get install -y curl nmap procps +RUN echo 'deb http://www.apache.org/dist/cassandra/debian 311x main' | tee --append /etc/apt/sources.list.d/cassandra.list > /dev/null +RUN curl https://www.apache.org/dist/cassandra/KEYS | apt-key add - +RUN apt-get update +RUN apt-get install -y cassandra cassandra-tools +RUN update-rc.d cassandra disable +RUN sed -i.old '/ulimit/d' /etc/init.d/cassandra + +COPY logback.xml ${pkg.name}.conf start-db.sh stop-db.sh start-tb.sh upgrade-tb.sh install-tb.sh ${pkg.name}.deb /tmp/ + +RUN chmod a+x /tmp/*.sh \ + && mv /tmp/start-tb.sh /usr/bin \ + && mv /tmp/upgrade-tb.sh /usr/bin \ + && mv /tmp/install-tb.sh /usr/bin \ + && mv /tmp/start-db.sh /usr/bin \ + && mv /tmp/stop-db.sh /usr/bin + +RUN dpkg -i /tmp/${pkg.name}.deb + +RUN update-rc.d ${pkg.name} disable + +RUN mv /tmp/logback.xml ${pkg.installFolder}/conf \ + && mv /tmp/${pkg.name}.conf ${pkg.installFolder}/conf + +ENV DATA_FOLDER=/data + +ENV HTTP_BIND_PORT=9090 +ENV DATABASE_TS_TYPE=cassandra +ENV DATABASE_ENTITIES_TYPE=cassandra + +ENV CASSANDRA_HOST=localhost +ENV CASSANDRA_PORT=9042 + +EXPOSE 9090 +EXPOSE 1883 +EXPOSE 5683/udp + +VOLUME ["/data"] + +CMD ["start-tb.sh"] diff --git a/docker/cassandra-setup/install.sh b/msa/tb/docker-cassandra/start-db.sh old mode 100755 new mode 100644 similarity index 62% rename from docker/cassandra-setup/install.sh rename to msa/tb/docker-cassandra/start-db.sh index 8578b2e769..c089bf65a6 --- a/docker/cassandra-setup/install.sh +++ b/msa/tb/docker-cassandra/start-db.sh @@ -15,19 +15,24 @@ # limitations under the License. # +cassandra_data_dir=${DATA_FOLDER}/db +cassandra_data_link=/var/lib/cassandra -dpkg -i /thingsboard.deb +if [ ! -L ${cassandra_data_link} ]; then + if [ -d ${cassandra_data_link} ]; then + rm -rf ${cassandra_data_link} + fi + if [ ! -d ${cassandra_data_dir} ]; then + mkdir -p ${cassandra_data_dir} + chown -R cassandra:cassandra ${cassandra_data_dir} + fi + ln -s ${cassandra_data_dir} ${cassandra_data_link} +fi + +service cassandra start until nmap $CASSANDRA_HOST -p $CASSANDRA_PORT | grep "$CASSANDRA_PORT/tcp open" do echo "Wait for cassandra db to start..." - sleep 10 + sleep 5 done - -echo "Creating 'Thingsboard' schema and system data..." -if [ "$ADD_DEMO_DATA" == "true" ]; then - echo "plus demo data..." - /usr/share/thingsboard/bin/install/install.sh --loadDemo -elif [ "$ADD_DEMO_DATA" == "false" ]; then - /usr/share/thingsboard/bin/install/install.sh -fi diff --git a/msa/docker/docker-update-service.sh b/msa/tb/docker-cassandra/stop-db.sh old mode 100755 new mode 100644 similarity index 90% rename from msa/docker/docker-update-service.sh rename to msa/tb/docker-cassandra/stop-db.sh index f698f9b015..8cb4b1210b --- a/msa/docker/docker-update-service.sh +++ b/msa/tb/docker-cassandra/stop-db.sh @@ -15,5 +15,4 @@ # limitations under the License. # -docker-compose pull $@ -docker-compose up -d --no-deps --build $@ +service cassandra stop diff --git a/msa/tb/docker-postgres/Dockerfile b/msa/tb/docker-postgres/Dockerfile new file mode 100644 index 0000000000..9447d51387 --- /dev/null +++ b/msa/tb/docker-postgres/Dockerfile @@ -0,0 +1,62 @@ +# +# 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. +# + +FROM openjdk:8-jre + +RUN apt-get update +RUN apt-get install -y postgresql postgresql-contrib +RUN update-rc.d postgresql disable + +RUN mkdir -p /var/log/postgres +RUN chown -R postgres:postgres /var/log/postgres + +COPY logback.xml ${pkg.name}.conf start-db.sh stop-db.sh start-tb.sh upgrade-tb.sh install-tb.sh ${pkg.name}.deb /tmp/ + +RUN chmod a+x /tmp/*.sh \ + && mv /tmp/start-tb.sh /usr/bin \ + && mv /tmp/upgrade-tb.sh /usr/bin \ + && mv /tmp/install-tb.sh /usr/bin \ + && mv /tmp/start-db.sh /usr/bin \ + && mv /tmp/stop-db.sh /usr/bin + +RUN dpkg -i /tmp/${pkg.name}.deb + +RUN update-rc.d ${pkg.name} disable + +RUN mv /tmp/logback.xml ${pkg.installFolder}/conf \ + && mv /tmp/${pkg.name}.conf ${pkg.installFolder}/conf + +ENV DATA_FOLDER=/data + +ENV HTTP_BIND_PORT=9090 +ENV DATABASE_TS_TYPE=sql +ENV DATABASE_ENTITIES_TYPE=sql + +ENV PGDATA=/data/db + +ENV SPRING_JPA_DATABASE_PLATFORM=org.hibernate.dialect.PostgreSQLDialect +ENV SPRING_DRIVER_CLASS_NAME=org.postgresql.Driver +ENV SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/thingsboard +ENV SPRING_DATASOURCE_USERNAME=postgres +ENV SPRING_DATASOURCE_PASSWORD=postgres + +EXPOSE 9090 +EXPOSE 1883 +EXPOSE 5683/udp + +VOLUME ["/data"] + +CMD ["start-tb.sh"] diff --git a/docker/cassandra-upgrade/upgrade.sh b/msa/tb/docker-postgres/start-db.sh old mode 100755 new mode 100644 similarity index 59% rename from docker/cassandra-upgrade/upgrade.sh rename to msa/tb/docker-postgres/start-db.sh index dac49191b2..4b973e6527 --- a/docker/cassandra-upgrade/upgrade.sh +++ b/msa/tb/docker-postgres/start-db.sh @@ -15,14 +15,16 @@ # limitations under the License. # +firstlaunch=${DATA_FOLDER}/.firstlaunch -dpkg -i /thingsboard.deb +if [ ! -d ${PGDATA} ]; then + mkdir -p ${PGDATA} + chown -R postgres:postgres ${PGDATA} + su postgres -c '/usr/lib/postgresql/9.6/bin/pg_ctl initdb -U postgres' +fi -until nmap $CASSANDRA_HOST -p $CASSANDRA_PORT | grep "$CASSANDRA_PORT/tcp open" -do - echo "Wait for cassandra db to start..." - sleep 10 -done +su postgres -c '/usr/lib/postgresql/9.6/bin/pg_ctl -l /var/log/postgres/postgres.log -w start' -echo "Upgrading 'Thingsboard' schema..." -/usr/share/thingsboard/bin/install/upgrade.sh --fromVersion=$UPGRADE_FROM_VERSION +if [ ! -f ${firstlaunch} ]; then + su postgres -c 'psql -U postgres -d postgres -c "CREATE DATABASE thingsboard"' +fi diff --git a/docker/cassandra/Dockerfile b/msa/tb/docker-postgres/stop-db.sh similarity index 84% rename from docker/cassandra/Dockerfile rename to msa/tb/docker-postgres/stop-db.sh index a4e5cc049b..b1db7caa9e 100644 --- a/docker/cassandra/Dockerfile +++ b/msa/tb/docker-postgres/stop-db.sh @@ -1,3 +1,4 @@ +#!/bin/bash # # Copyright © 2016-2018 The Thingsboard Authors # @@ -14,10 +15,4 @@ # limitations under the License. # -FROM cassandra:3.11.2 - -ADD ready-probe.sh /ready-probe.sh - -RUN chmod +x /ready-probe.sh - -CMD ["cassandra", "-f"] \ No newline at end of file +su postgres -c '/usr/lib/postgresql/9.6/bin/pg_ctl stop' diff --git a/msa/tb/docker-tb/Dockerfile b/msa/tb/docker-tb/Dockerfile new file mode 100644 index 0000000000..df7e692fbe --- /dev/null +++ b/msa/tb/docker-tb/Dockerfile @@ -0,0 +1,48 @@ +# +# 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. +# + +FROM openjdk:8-jre + +COPY logback.xml ${pkg.name}.conf start-db.sh stop-db.sh start-tb.sh upgrade-tb.sh install-tb.sh ${pkg.name}.deb /tmp/ + +RUN chmod a+x /tmp/*.sh \ + && mv /tmp/start-tb.sh /usr/bin \ + && mv /tmp/upgrade-tb.sh /usr/bin \ + && mv /tmp/install-tb.sh /usr/bin \ + && mv /tmp/start-db.sh /usr/bin \ + && mv /tmp/stop-db.sh /usr/bin + +RUN dpkg -i /tmp/${pkg.name}.deb + +RUN update-rc.d ${pkg.name} disable + +RUN mv /tmp/logback.xml ${pkg.installFolder}/conf \ + && mv /tmp/${pkg.name}.conf ${pkg.installFolder}/conf + +ENV DATA_FOLDER=/data + +ENV HTTP_BIND_PORT=9090 +ENV DATABASE_TS_TYPE=sql +ENV DATABASE_ENTITIES_TYPE=sql +ENV SQL_DATA_FOLDER=/data/db + +EXPOSE 9090 +EXPOSE 1883 +EXPOSE 5683/udp + +VOLUME ["/data"] + +CMD ["start-tb.sh"] diff --git a/docker/docker-compose-tests.yml b/msa/tb/docker-tb/start-db.sh similarity index 81% rename from docker/docker-compose-tests.yml rename to msa/tb/docker-tb/start-db.sh index 64868b5a1f..779e69c3eb 100644 --- a/docker/docker-compose-tests.yml +++ b/msa/tb/docker-tb/start-db.sh @@ -1,3 +1,4 @@ +#!/bin/bash # # Copyright © 2016-2018 The Thingsboard Authors # @@ -14,14 +15,4 @@ # limitations under the License. # -version: '3.3' -services: - redis: - image: redis:4.0 - networks: - - core - ports: - - "6379:6379" - -networks: - core: +# Do nothing \ No newline at end of file diff --git a/docker/docker-compose.static.yml b/msa/tb/docker-tb/stop-db.sh similarity index 78% rename from docker/docker-compose.static.yml rename to msa/tb/docker-tb/stop-db.sh index 4a0688a2da..779e69c3eb 100644 --- a/docker/docker-compose.static.yml +++ b/msa/tb/docker-tb/stop-db.sh @@ -1,3 +1,4 @@ +#!/bin/bash # # Copyright © 2016-2018 The Thingsboard Authors # @@ -14,16 +15,4 @@ # limitations under the License. # -version: '2' - -services: - cassandra: - ports: - - "9042:9042" - - "9160:9160" - zk: - ports: - - "2181:2181" - postgres: - ports: - - "5432:5432" \ No newline at end of file +# Do nothing \ No newline at end of file diff --git a/msa/tb/docker/install-tb.sh b/msa/tb/docker/install-tb.sh new file mode 100644 index 0000000000..e22ec58ec2 --- /dev/null +++ b/msa/tb/docker/install-tb.sh @@ -0,0 +1,56 @@ +#!/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. +# + +while [[ $# -gt 0 ]] +do +key="$1" + +case $key in + --loadDemo) + LOAD_DEMO=true + shift # past argument + ;; + *) + # unknown option + ;; +esac +shift # past argument or value +done + +if [ "$LOAD_DEMO" == "true" ]; then + loadDemo=true +else + loadDemo=false +fi + +CONF_FOLDER="${pkg.installFolder}/conf" +jarfile=${pkg.installFolder}/bin/${pkg.name}.jar +configfile=${pkg.name}.conf +upgradeversion=${DATA_FOLDER}/.upgradeversion + +source "${CONF_FOLDER}/${configfile}" + +echo "Starting ThingsBoard installation ..." + +java -cp ${jarfile} $JAVA_OPTS -Dloader.main=org.thingsboard.server.ThingsboardInstallApplication \ + -Dinstall.load_demo=${loadDemo} \ + -Dspring.jpa.hibernate.ddl-auto=none \ + -Dinstall.upgrade=false \ + -Dlogging.config=/usr/share/thingsboard/bin/install/logback.xml \ + org.springframework.boot.loader.PropertiesLauncher + +echo "${pkg.upgradeVersion}" > ${upgradeversion} diff --git a/msa/tb/docker/logback.xml b/msa/tb/docker/logback.xml new file mode 100644 index 0000000000..87f9bf4c06 --- /dev/null +++ b/msa/tb/docker/logback.xml @@ -0,0 +1,51 @@ + + + + + + + /var/log/thingsboard/thingsboard.log + + /var/log/thingsboard/thingsboard.%d{yyyy-MM-dd}.%i.log + 100MB + 30 + 3GB + + + %d{ISO8601} [%thread] %-5level %logger{36} - %msg%n + + + + + + %d{ISO8601} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + + + + + \ No newline at end of file diff --git a/msa/tb/docker/start-tb.sh b/msa/tb/docker/start-tb.sh new file mode 100755 index 0000000000..37f5e3a72a --- /dev/null +++ b/msa/tb/docker/start-tb.sh @@ -0,0 +1,39 @@ +#!/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. +# + +start-db.sh + +CONF_FOLDER="${pkg.installFolder}/conf" +jarfile=${pkg.installFolder}/bin/${pkg.name}.jar +configfile=${pkg.name}.conf +firstlaunch=${DATA_FOLDER}/.firstlaunch + +source "${CONF_FOLDER}/${configfile}" + +if [ ! -f ${firstlaunch} ]; then + install-tb.sh --loadDemo + touch ${firstlaunch} +fi + +echo "Starting ThingsBoard ..." + +java -cp ${jarfile} $JAVA_OPTS -Dloader.main=org.thingsboard.server.ThingsboardServerApplication \ + -Dspring.jpa.hibernate.ddl-auto=none \ + -Dlogging.config=${CONF_FOLDER}/logback.xml \ + org.springframework.boot.loader.PropertiesLauncher + +stop-db.sh \ No newline at end of file diff --git a/msa/tb/docker/thingsboard.conf b/msa/tb/docker/thingsboard.conf new file mode 100644 index 0000000000..85d7cfd871 --- /dev/null +++ b/msa/tb/docker/thingsboard.conf @@ -0,0 +1,24 @@ +# +# 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. +# + +export JAVA_OPTS="$JAVA_OPTS -Dplatform=deb -Dinstall.data_dir=/usr/share/thingsboard/data" +export JAVA_OPTS="$JAVA_OPTS -Xloggc:/var/log/thingsboard/gc.log -XX:+IgnoreUnrecognizedVMOptions -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCDetails -XX:+PrintGCDateStamps" +export JAVA_OPTS="$JAVA_OPTS -XX:+PrintHeapAtGC -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10" +export JAVA_OPTS="$JAVA_OPTS -XX:GCLogFileSize=10M -XX:-UseBiasedLocking -XX:+UseTLAB -XX:+ResizeTLAB -XX:+PerfDisableSharedMem -XX:+UseCondCardMark" +export JAVA_OPTS="$JAVA_OPTS -XX:CMSWaitDuration=10000 -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+CMSParallelInitialMarkEnabled" +export JAVA_OPTS="$JAVA_OPTS -XX:+CMSEdenChunksRecordAlways -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+ExitOnOutOfMemoryError" +export LOG_FILENAME=thingsboard.out +export LOADER_PATH=/usr/share/thingsboard/conf,/usr/share/thingsboard/extensions diff --git a/msa/tb/docker/upgrade-tb.sh b/msa/tb/docker/upgrade-tb.sh new file mode 100644 index 0000000000..ab77cddf4c --- /dev/null +++ b/msa/tb/docker/upgrade-tb.sh @@ -0,0 +1,47 @@ +#!/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. +# + +start-db.sh + +CONF_FOLDER="${pkg.installFolder}/conf" +jarfile=${pkg.installFolder}/bin/${pkg.name}.jar +configfile=${pkg.name}.conf +upgradeversion=${DATA_FOLDER}/.upgradeversion + +source "${CONF_FOLDER}/${configfile}" + +FROM_VERSION=`cat ${upgradeversion}` + +echo "Starting ThingsBoard upgrade ..." + +if [[ -z "${FROM_VERSION// }" ]]; then + echo "FROM_VERSION variable is invalid or unspecified!" + exit 1 +else + fromVersion="${FROM_VERSION// }" +fi + +java -cp ${jarfile} $JAVA_OPTS -Dloader.main=org.thingsboard.server.ThingsboardInstallApplication \ + -Dspring.jpa.hibernate.ddl-auto=none \ + -Dinstall.upgrade=true \ + -Dinstall.upgrade.from_version=${fromVersion} \ + -Dlogging.config=/usr/share/thingsboard/bin/install/logback.xml \ + org.springframework.boot.loader.PropertiesLauncher + +echo "${pkg.upgradeVersion}" > ${upgradeversion} + +stop-db.sh \ No newline at end of file diff --git a/msa/tb/pom.xml b/msa/tb/pom.xml new file mode 100644 index 0000000000..6ea7bebae2 --- /dev/null +++ b/msa/tb/pom.xml @@ -0,0 +1,370 @@ + + + 4.0.0 + + org.thingsboard + 2.2.0-SNAPSHOT + msa + + org.thingsboard.msa + tb + pom + + ThingsBoard Docker Images + https://thingsboard.io + ThingsBoard Docker Images + + + UTF-8 + ${basedir}/../.. + thingsboard + tb + tb-postgres + tb-cassandra + thingsboard + /usr/share/${pkg.name} + 2.1.1 + + + + + org.thingsboard + application + ${project.version} + deb + deb + provided + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-tb-deb + package + + copy + + + + + org.thingsboard + application + deb + deb + ${pkg.name}.deb + ${project.build.directory}/docker-tb + + + + + + copy-tb-postgres-deb + package + + copy + + + + + org.thingsboard + application + deb + deb + ${pkg.name}.deb + ${project.build.directory}/docker-postgres + + + + + + copy-tb-cassandra-deb + package + + copy + + + + + org.thingsboard + application + deb + deb + ${pkg.name}.deb + ${project.build.directory}/docker-cassandra + + + + + + + + org.apache.maven.plugins + maven-resources-plugin + + + copy-docker-tb-config + process-resources + + copy-resources + + + ${project.build.directory}/docker-tb + + + docker + true + + + docker-tb + true + + + + + + copy-docker-tb-postgres-config + process-resources + + copy-resources + + + ${project.build.directory}/docker-postgres + + + docker + true + + + docker-postgres + true + + + + + + copy-docker-tb-cassandra-config + process-resources + + copy-resources + + + ${project.build.directory}/docker-cassandra + + + docker + true + + + docker-cassandra + true + + + + + + + + com.spotify + dockerfile-maven-plugin + + + build-docker-tb-image + pre-integration-test + + build + + + ${dockerfile.skip} + ${docker.repo}/${tb.docker.name} + true + false + ${project.build.directory}/docker-tb + + + + tag-docker-tb-image + pre-integration-test + + tag + + + ${dockerfile.skip} + ${docker.repo}/${tb.docker.name} + ${project.version} + + + + build-docker-tb-postgres-image + pre-integration-test + + build + + + ${dockerfile.skip} + ${docker.repo}/${tb-postgres.docker.name} + true + false + ${project.build.directory}/docker-postgres + + + + tag-docker-tb-postgres-image + pre-integration-test + + tag + + + ${dockerfile.skip} + ${docker.repo}/${tb-postgres.docker.name} + ${project.version} + + + + build-docker-tb-cassandra-image + pre-integration-test + + build + + + ${dockerfile.skip} + ${docker.repo}/${tb-cassandra.docker.name} + true + false + ${project.build.directory}/docker-cassandra + + + + tag-docker-tb-cassandra-image + pre-integration-test + + tag + + + ${dockerfile.skip} + ${docker.repo}/${tb-cassandra.docker.name} + ${project.version} + + + + + + + + + push-docker-image + + + push-docker-image + + + + + + com.spotify + dockerfile-maven-plugin + + + push-latest-docker-tb-image + pre-integration-test + + push + + + latest + ${docker.repo}/${tb.docker.name} + + + + push-version-docker-tb-image + pre-integration-test + + push + + + ${project.version} + ${docker.repo}/${tb.docker.name} + + + + push-latest-docker-tb-postgres-image + pre-integration-test + + push + + + latest + ${docker.repo}/${tb-postgres.docker.name} + + + + push-version-docker-tb-postgres-image + pre-integration-test + + push + + + ${project.version} + ${docker.repo}/${tb-postgres.docker.name} + + + + push-latest-docker-tb-cassandra-image + pre-integration-test + + push + + + latest + ${docker.repo}/${tb-cassandra.docker.name} + + + + push-version-docker-tb-cassandra-image + pre-integration-test + + push + + + ${project.version} + ${docker.repo}/${tb-cassandra.docker.name} + + + + + + + + + + + jenkins + Jenkins Repository + http://repo.jenkins-ci.org/releases + + false + + + + diff --git a/msa/transport/coap/pom.xml b/msa/transport/coap/pom.xml index 94399c7715..26eaa30e0a 100644 --- a/msa/transport/coap/pom.xml +++ b/msa/transport/coap/pom.xml @@ -111,19 +111,72 @@ build + + ${dockerfile.skip} + ${docker.repo}/${docker.name} + true + false + ${project.build.directory} + + + + tag-docker-image + pre-integration-test + + tag + + + ${dockerfile.skip} + ${docker.repo}/${docker.name} + ${project.version} + - - ${dockerfile.skip} - ${docker.repo}/${docker.name} - ${project.version} - true - false - ${project.build.directory} - + + + push-docker-image + + + push-docker-image + + + + + + com.spotify + dockerfile-maven-plugin + + + push-latest-docker-image + pre-integration-test + + push + + + latest + ${docker.repo}/${docker.name} + + + + push-version-docker-image + pre-integration-test + + push + + + ${project.version} + ${docker.repo}/${docker.name} + + + + + + + + jenkins diff --git a/msa/transport/http/pom.xml b/msa/transport/http/pom.xml index 6bbfc3f782..6d1707c4f7 100644 --- a/msa/transport/http/pom.xml +++ b/msa/transport/http/pom.xml @@ -111,19 +111,72 @@ build + + ${dockerfile.skip} + ${docker.repo}/${docker.name} + true + false + ${project.build.directory} + + + + tag-docker-image + pre-integration-test + + tag + + + ${dockerfile.skip} + ${docker.repo}/${docker.name} + ${project.version} + - - ${dockerfile.skip} - ${docker.repo}/${docker.name} - ${project.version} - true - false - ${project.build.directory} - + + + push-docker-image + + + push-docker-image + + + + + + com.spotify + dockerfile-maven-plugin + + + push-latest-docker-image + pre-integration-test + + push + + + latest + ${docker.repo}/${docker.name} + + + + push-version-docker-image + pre-integration-test + + push + + + ${project.version} + ${docker.repo}/${docker.name} + + + + + + + + jenkins diff --git a/msa/transport/mqtt/pom.xml b/msa/transport/mqtt/pom.xml index 0a3b07771b..d51c51c035 100644 --- a/msa/transport/mqtt/pom.xml +++ b/msa/transport/mqtt/pom.xml @@ -111,19 +111,72 @@ build + + ${dockerfile.skip} + ${docker.repo}/${docker.name} + true + false + ${project.build.directory} + + + + tag-docker-image + pre-integration-test + + tag + + + ${dockerfile.skip} + ${docker.repo}/${docker.name} + ${project.version} + - - ${dockerfile.skip} - ${docker.repo}/${docker.name} - ${project.version} - true - false - ${project.build.directory} - + + + push-docker-image + + + push-docker-image + + + + + + com.spotify + dockerfile-maven-plugin + + + push-latest-docker-image + pre-integration-test + + push + + + latest + ${docker.repo}/${docker.name} + + + + push-version-docker-image + pre-integration-test + + push + + + ${project.version} + ${docker.repo}/${docker.name} + + + + + + + + jenkins diff --git a/msa/web-ui/pom.xml b/msa/web-ui/pom.xml index 805bf8b821..83124dff06 100644 --- a/msa/web-ui/pom.xml +++ b/msa/web-ui/pom.xml @@ -311,16 +311,27 @@ build + + ${dockerfile.skip} + ${docker.repo}/${docker.name} + true + false + ${project.build.directory} + + + + tag-docker-image + pre-integration-test + + tag + + + ${dockerfile.skip} + ${docker.repo}/${docker.name} + ${project.version} + - - ${dockerfile.skip} - ${docker.repo}/${docker.name} - ${project.version} - true - false - ${project.build.directory} - @@ -358,6 +369,46 @@ + + push-docker-image + + + push-docker-image + + + + + + com.spotify + dockerfile-maven-plugin + + + push-latest-docker-image + pre-integration-test + + push + + + latest + ${docker.repo}/${docker.name} + + + + push-version-docker-image + pre-integration-test + + push + + + ${project.version} + ${docker.repo}/${docker.name} + + + + + + +