28 changed files with 663 additions and 29 deletions
@ -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 |
|||
@ -0,0 +1,4 @@ |
|||
haproxy/certs.d/** |
|||
haproxy/letsencrypt/** |
|||
tb-node/log/** |
|||
!.env |
|||
@ -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 |
|||
|
|||
|
|||
@ -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 |
|||
@ -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 |
|||
@ -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 |
|||
@ -0,0 +1,4 @@ |
|||
# Ignore everything in this directory |
|||
* |
|||
# Except this file |
|||
!.gitignore |
|||
@ -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] |
|||
@ -0,0 +1,4 @@ |
|||
# Ignore everything in this directory |
|||
* |
|||
# Except this file |
|||
!.gitignore |
|||
@ -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 |
|||
@ -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> |
|||
@ -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 |
|||
@ -0,0 +1,4 @@ |
|||
# Ignore everything in this directory |
|||
* |
|||
# Except this file |
|||
!.gitignore |
|||
@ -0,0 +1,4 @@ |
|||
# Ignore everything in this directory |
|||
* |
|||
# Except this file |
|||
!.gitignore |
|||
@ -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"] |
|||
@ -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 |
|||
@ -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> |
|||
Loading…
Reference in new issue