Browse Source

Add tb-node docker image. Improve TB docker services.

pull/1150/head
Igor Kulikov 8 years ago
parent
commit
8af8b27e7e
  1. 21
      application/pom.xml
  2. 4
      application/src/main/resources/thingsboard.yml
  3. 11
      common/queue/src/main/java/org/thingsboard/server/kafka/TBKafkaAdmin.java
  4. 6
      common/queue/src/main/java/org/thingsboard/server/kafka/TBKafkaProducerTemplate.java
  5. 5
      common/queue/src/main/java/org/thingsboard/server/kafka/TbKafkaRequestTemplate.java
  6. 7
      msa/docker/.env
  7. 4
      msa/docker/.gitignore
  8. 78
      msa/docker/docker-compose.yml
  9. 42
      msa/docker/docker-install-tb.sh
  10. 18
      msa/docker/docker-start-services.sh
  11. 18
      msa/docker/docker-stop-services.sh
  12. 39
      msa/docker/docker-upgrade-tb.sh
  13. 4
      msa/docker/haproxy/certs.d/.gitignore
  14. 61
      msa/docker/haproxy/config/haproxy.cfg
  15. 4
      msa/docker/haproxy/letsencrypt/.gitignore
  16. 23
      msa/docker/tb-node.env
  17. 51
      msa/docker/tb-node/conf/logback.xml
  18. 24
      msa/docker/tb-node/conf/thingsboard.conf
  19. 4
      msa/docker/tb-node/db/.gitignore
  20. 4
      msa/docker/tb-node/log/.gitignore
  21. 2
      msa/docker/tb-web-ui.env
  22. 5
      msa/js-executor/pom.xml
  23. 15
      msa/pom.xml
  24. 28
      msa/tb-node/docker/Dockerfile
  25. 71
      msa/tb-node/docker/start-tb-node.sh
  26. 136
      msa/tb-node/pom.xml
  27. 5
      msa/web-ui/pom.xml
  28. 2
      pom.xml

21
application/pom.xml

@ -576,6 +576,27 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<configuration>
<file>${project.build.directory}/${pkg.name}.deb</file>
<artifactId>${project.artifactId}</artifactId>
<groupId>${project.groupId}</groupId>
<version>${project.version}</version>
<classifier>deb</classifier>
<packaging>deb</packaging>
</configuration>
<executions>
<execution>
<id>install-deb</id>
<phase>package</phase>
<goals>
<goal>install-file</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>

4
application/src/main/resources/thingsboard.yml

@ -407,7 +407,7 @@ state:
kafka:
enabled: true
bootstrap.servers: "${TB_KAFKA_SERVERS:192.168.2.157:9092}"
bootstrap.servers: "${TB_KAFKA_SERVERS:localhost:9092}"
acks: "${TB_KAFKA_ACKS:all}"
retries: "${TB_KAFKA_RETRIES:1}"
batch.size: "${TB_KAFKA_BATCH_SIZE:16384}"
@ -415,7 +415,7 @@ kafka:
buffer.memory: "${TB_BUFFER_MEMORY:33554432}"
js:
evaluator: "${JS_EVALUATOR:remote}" # local/remote
evaluator: "${JS_EVALUATOR:local}" # local/remote
# Built-in JVM JavaScript environment properties
local:
# Use Sandboxed (secured) JVM JavaScript environment

11
common/queue/src/main/java/org/thingsboard/server/kafka/TBKafkaAdmin.java

@ -32,15 +32,8 @@ public class TBKafkaAdmin {
AdminClient client;
public TBKafkaAdmin() {
Properties props = new Properties();
props.put("bootstrap.servers", "localhost:9092");
props.put("group.id", "test");
props.put("enable.auto.commit", "true");
props.put("auto.commit.interval.ms", "1000");
props.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
props.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
client = AdminClient.create(props);
public TBKafkaAdmin(TbKafkaSettings settings) {
client = AdminClient.create(settings.toProps());
}
public CreateTopicsResult createTopic(NewTopic topic){

6
common/queue/src/main/java/org/thingsboard/server/kafka/TBKafkaProducerTemplate.java

@ -52,12 +52,16 @@ public class TBKafkaProducerTemplate<T> {
@Getter
private final String defaultTopic;
@Getter
private final TbKafkaSettings settings;
@Builder
private TBKafkaProducerTemplate(TbKafkaSettings settings, TbKafkaEncoder<T> encoder, TbKafkaEnricher<T> enricher,
TbKafkaPartitioner<T> partitioner, String defaultTopic) {
Properties props = settings.toProps();
props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringSerializer");
props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.ByteArraySerializer");
this.settings = settings;
this.producer = new KafkaProducer<>(props);
this.encoder = encoder;
this.enricher = enricher;
@ -67,7 +71,7 @@ public class TBKafkaProducerTemplate<T> {
public void init() {
try {
TBKafkaAdmin admin = new TBKafkaAdmin();
TBKafkaAdmin admin = new TBKafkaAdmin(this.settings);
CreateTopicsResult result = admin.createTopic(new NewTopic(defaultTopic, 100, (short) 1));
result.all().get();
} catch (Exception e) {

5
common/queue/src/main/java/org/thingsboard/server/kafka/TbKafkaRequestTemplate.java

@ -55,7 +55,8 @@ public class TbKafkaRequestTemplate<Request, Response> {
private volatile boolean stopped = false;
@Builder
public TbKafkaRequestTemplate(TBKafkaProducerTemplate<Request> requestTemplate, TBKafkaConsumerTemplate<Response> responseTemplate,
public TbKafkaRequestTemplate(TBKafkaProducerTemplate<Request> requestTemplate,
TBKafkaConsumerTemplate<Response> responseTemplate,
long maxRequestTimeout,
long maxPendingRequests,
long pollInterval,
@ -77,7 +78,7 @@ public class TbKafkaRequestTemplate<Request, Response> {
public void init() {
try {
TBKafkaAdmin admin = new TBKafkaAdmin();
TBKafkaAdmin admin = new TBKafkaAdmin(this.requestTemplate.getSettings());
CreateTopicsResult result = admin.createTopic(new NewTopic(responseTemplate.getTopic(), 1, (short) 1));
result.all().get();
} catch (Exception e) {

7
msa/docker/.env

@ -0,0 +1,7 @@
DOCKER_REPO=local-maven-build
TB_VERSION=2.2.0-SNAPSHOT
KAFKA_TOPICS=js.eval.requests:100:1
HTTP_PORT=80
HTTPS_PORT=80

4
msa/docker/.gitignore

@ -0,0 +1,4 @@
haproxy/certs.d/**
haproxy/letsencrypt/**
tb-node/log/**
!.env

78
msa/docker/docker-compose.yml

@ -19,17 +19,19 @@ version: '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://${EXTERNAL_HOSTNAME}: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}"
@ -37,21 +39,81 @@ services:
depends_on:
- zookeeper
tb-js-executor:
image: "local-maven-build/tb-js-executor:latest"
restart: always
image: "${DOCKER_REPO}/tb-js-executor:${TB_VERSION}"
environment:
TB_KAFKA_SERVERS: kafka:9092
env_file:
- tb-js-executor.env
depends_on:
- kafka
tb-web-ui:
image: "local-maven-build/tb-web-ui:latest"
tb:
restart: always
image: "${DOCKER_REPO}/tb-node:${TB_VERSION}"
ports:
- "8090:8090"
- "8080"
- "1883:1883"
- "5683:5683/udp"
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-web-ui1:
restart: always
image: "${DOCKER_REPO}/tb-web-ui:${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}/tb-web-ui:${TB_VERSION}"
ports:
- "8080"
environment:
HTTP_BIND_ADDRESS: 0.0.0.0
HTTP_BIND_PORT: 8090
TB_HOST: ${EXTERNAL_HOSTNAME}
TB_HOST: tb
TB_PORT: 8080
env_file:
- tb-web-ui.env
tb-web-ui3:
restart: always
image: "${DOCKER_REPO}/tb-web-ui:${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"
- "9999:9999"
cap_add:
- NET_ADMIN
environment:
HTTP_PORT: ${HTTP_PORT}
HTTPS_PORT: ${HTTPS_PORT}
links:
- tb-web-ui1
- tb-web-ui2
- tb-web-ui3

42
msa/docker/docker-install-tb.sh

@ -0,0 +1,42 @@
#!/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
docker-compose run --rm -e INSTALL_TB=true -e LOAD_DEMO=${loadDemo} tb

18
msa/docker/docker-start-services.sh

@ -0,0 +1,18 @@
#!/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.
#
docker-compose up -d

18
msa/docker/docker-stop-services.sh

@ -0,0 +1,18 @@
#!/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.
#
docker-compose down

39
msa/docker/docker-upgrade-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.
#
for i in "$@"
do
case $i in
--fromVersion=*)
FROM_VERSION="${i#*=}"
shift
;;
*)
# unknown option
;;
esac
done
if [[ -z "${FROM_VERSION// }" ]]; then
echo "--fromVersion parameter is invalid or unspecified!"
echo "Usage: docker-upgrade-tb.sh --fromVersion={VERSION}"
exit 1
else
fromVersion="${FROM_VERSION// }"
fi
docker-compose run --rm -e UPGRADE_TB=true -e FROM_VERSION=${fromVersion} tb

4
msa/docker/haproxy/certs.d/.gitignore

@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

61
msa/docker/haproxy/config/haproxy.cfg

@ -0,0 +1,61 @@
#HA Proxy Config
global
maxconn 4096
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
ca-base /etc/ssl/certs
crt-base /etc/ssl/private
ssl-default-bind-ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS
ssl-default-bind-options no-sslv3
defaults
option forwardfor
log global
mode http
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
listen stats
bind *:9999
stats enable
stats hide-version
stats uri /stats
stats auth admin:admin@123
frontend http-in
bind *:${HTTP_PORT}
reqadd X-Forwarded-Proto:\ http
acl letsencrypt_http_acl path_beg /.well-known/acme-challenge/
redirect scheme https if !letsencrypt_http_acl
use_backend letsencrypt_http if letsencrypt_http_acl
default_backend tb-web-backend
frontend https_in
bind *:${HTTPS_PORT} ssl crt /usr/local/etc/haproxy/default.pem crt /usr/local/etc/haproxy/certs.d ciphers ECDHE-RSA-AES256-SHA:RC4-SHA:RC4:HIGH:!MD5:!aNULL:!EDH:!AESGCM
reqadd X-Forwarded-Proto:\ https
default_backend tb-web-backend
backend letsencrypt_http
server letsencrypt_http_srv 127.0.0.1:8080
backend tb-web-backend
balance leastconn
option tcp-check
option log-health-checks
server tbWeb1 tb-web-ui1:8080 check
server tbWeb2 tb-web-ui2:8080 check
server tbWeb3 tb-web-ui3:8080 check
http-request set-header X-Forwarded-Port %[dst_port]

4
msa/docker/haproxy/letsencrypt/.gitignore

@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

23
msa/docker/tb-node.env

@ -0,0 +1,23 @@
# 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
# type of database to use: sql[DEFAULT] or cassandra
DATABASE_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

51
msa/docker/tb-node/conf/logback.xml

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
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.
-->
<!DOCTYPE configuration>
<configuration scan="true" scanPeriod="10 seconds">
<appender name="fileLogAppender"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>/var/log/thingsboard/thingsboard.log</file>
<rollingPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>/var/log/thingsboard/thingsboard.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<maxFileSize>100MB</maxFileSize>
<maxHistory>30</maxHistory>
<totalSizeCap>3GB</totalSizeCap>
</rollingPolicy>
<encoder>
<pattern>%d{ISO8601} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{ISO8601} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<logger name="org.thingsboard.server" level="INFO" />
<logger name="akka" level="INFO" />
<root level="INFO">
<appender-ref ref="fileLogAppender"/>
<appender-ref ref="STDOUT"/>
</root>
</configuration>

24
msa/docker/tb-node/conf/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"
export LOG_FILENAME=thingsboard.out
export LOADER_PATH=/usr/share/thingsboard/conf,/usr/share/thingsboard/extensions

4
msa/docker/tb-node/db/.gitignore

@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

4
msa/docker/tb-node/log/.gitignore

@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

2
msa/docker/tb-web-ui.env

@ -1,6 +1,6 @@
HTTP_BIND_ADDRESS=0.0.0.0
HTTP_BIND_PORT=8090
HTTP_BIND_PORT=8080
TB_HOST=localhost
TB_PORT=8080
LOGGER_LEVEL=debug

5
msa/js-executor/pom.xml

@ -40,7 +40,6 @@
<pkg.installFolder>/usr/share/${pkg.name}</pkg.installFolder>
<pkg.linux.dist>${project.build.directory}/package/linux</pkg.linux.dist>
<pkg.win.dist>${project.build.directory}/package/windows</pkg.win.dist>
<dockerfile.skip>true</dockerfile.skip>
</properties>
<dependencies>
@ -280,7 +279,6 @@
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>1.4.4</version>
<executions>
<execution>
<id>build-docker-image</id>
@ -292,7 +290,8 @@
</executions>
<configuration>
<skip>${dockerfile.skip}</skip>
<repository>local-maven-build/${pkg.name}</repository>
<repository>${docker.repo}/${pkg.name}</repository>
<tag>${project.version}</tag>
<verbose>true</verbose>
<googleContainerRegistryEnabled>false</googleContainerRegistryEnabled>
<contextDirectory>${project.build.directory}</contextDirectory>

15
msa/pom.xml

@ -32,11 +32,26 @@
<properties>
<main.dir>${basedir}/..</main.dir>
<docker.repo>local-maven-build</docker.repo>
<dockerfile.skip>true</dockerfile.skip>
</properties>
<modules>
<module>js-executor</module>
<module>web-ui</module>
<module>tb-node</module>
</modules>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>1.4.5</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

28
msa/tb-node/docker/Dockerfile

@ -0,0 +1,28 @@
#
# 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 start-tb-node.sh ${pkg.name}.deb /tmp/
RUN chmod a+x /tmp/*.sh \
&& mv /tmp/start-tb-node.sh /usr/bin
RUN dpkg -i /tmp/${pkg.name}.deb
RUN update-rc.d ${pkg.name} disable
CMD ["start-tb-node.sh"]

71
msa/tb-node/docker/start-tb-node.sh

@ -0,0 +1,71 @@
#!/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.
#
CONF_FOLDER="/config"
jarfile=${pkg.installFolder}/bin/${pkg.name}.jar
configfile=${pkg.name}.conf
run_user=${pkg.name}
source "${CONF_FOLDER}/${configfile}"
export LOADER_PATH=/config,${LOADER_PATH}
if [ "$INSTALL_TB" == "true" ]; then
if [ "$LOAD_DEMO" == "true" ]; then
loadDemo=true
else
loadDemo=false
fi
echo "Starting ThingsBoard installation ..."
exec 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
elif [ "$UPGRADE_TB" == "true" ]; then
echo "Starting ThingsBoard upgrade ..."
if [[ -z "${FROM_VERSION// }" ]]; then
echo "FROM_VERSION variable is invalid or unspecified!"
exit 1
else
fromVersion="${FROM_VERSION// }"
fi
exec 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
else
echo "Starting '${project.name}' ..."
exec java -cp ${jarfile} $JAVA_OPTS -Dloader.main=org.thingsboard.server.ThingsboardServerApplication \
-Dspring.jpa.hibernate.ddl-auto=none \
-Dlogging.config=/config/logback.xml \
org.springframework.boot.loader.PropertiesLauncher
fi

136
msa/tb-node/pom.xml

@ -0,0 +1,136 @@
<!--
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.thingsboard</groupId>
<version>2.2.0-SNAPSHOT</version>
<artifactId>msa</artifactId>
</parent>
<groupId>org.thingsboard.msa</groupId>
<artifactId>tb-node</artifactId>
<packaging>pom</packaging>
<name>ThingsBoard Node Microservice</name>
<url>https://thingsboard.io</url>
<description>ThingsBoard Node Microservice</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<main.dir>${basedir}/../..</main.dir>
<pkg.name>thingsboard</pkg.name>
<pkg.user>thingsboard</pkg.user>
<pkg.unixLogFolder>/var/log/${pkg.name}</pkg.unixLogFolder>
<pkg.installFolder>/usr/share/${pkg.name}</pkg.installFolder>
</properties>
<dependencies>
<dependency>
<groupId>org.thingsboard</groupId>
<artifactId>application</artifactId>
<version>${project.version}</version>
<classifier>deb</classifier>
<type>deb</type>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-tb-deb</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.thingsboard</groupId>
<artifactId>application</artifactId>
<classifier>deb</classifier>
<type>deb</type>
<destFileName>${pkg.name}.deb</destFileName>
<outputDirectory>${project.build.directory}</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-docker-config</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}</outputDirectory>
<resources>
<resource>
<directory>docker</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<executions>
<execution>
<id>build-docker-image</id>
<phase>pre-integration-test</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
<configuration>
<skip>${dockerfile.skip}</skip>
<repository>${docker.repo}/tb-node</repository>
<tag>${project.version}</tag>
<verbose>true</verbose>
<googleContainerRegistryEnabled>false</googleContainerRegistryEnabled>
<contextDirectory>${project.build.directory}</contextDirectory>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>jenkins</id>
<name>Jenkins Repository</name>
<url>http://repo.jenkins-ci.org/releases</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</project>

5
msa/web-ui/pom.xml

@ -40,7 +40,6 @@
<pkg.installFolder>/usr/share/${pkg.name}</pkg.installFolder>
<pkg.linux.dist>${project.build.directory}/package/linux</pkg.linux.dist>
<pkg.win.dist>${project.build.directory}/package/windows</pkg.win.dist>
<dockerfile.skip>true</dockerfile.skip>
</properties>
<dependencies>
@ -304,7 +303,6 @@
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>1.4.4</version>
<executions>
<execution>
<id>build-docker-image</id>
@ -316,7 +314,8 @@
</executions>
<configuration>
<skip>${dockerfile.skip}</skip>
<repository>local-maven-build/${pkg.name}</repository>
<repository>${docker.repo}/${pkg.name}</repository>
<tag>${project.version}</tag>
<verbose>true</verbose>
<googleContainerRegistryEnabled>false</googleContainerRegistryEnabled>
<contextDirectory>${project.build.directory}</contextDirectory>

2
pom.xml

@ -284,6 +284,8 @@
<exclude>src/main/scripts/windows/**</exclude>
<exclude>src/main/resources/public/static/rulenode/**</exclude>
<exclude>**/*.proto.js</exclude>
<exclude>docker/haproxy/**</exclude>
<exclude>docker/tb-node/**</exclude>
</excludes>
<mapping>
<proto>JAVADOC_STYLE</proto>

Loading…
Cancel
Save