Commit 8af8b27e7e8e76d2b2fc409865da2cc8f99cd335
1 parent
4bf57ebf
Add tb-node docker image. Improve TB docker services.
Showing
28 changed files
with
663 additions
and
29 deletions
... | ... | @@ -577,6 +577,27 @@ |
577 | 577 | </executions> |
578 | 578 | </plugin> |
579 | 579 | <plugin> |
580 | + <groupId>org.apache.maven.plugins</groupId> | |
581 | + <artifactId>maven-install-plugin</artifactId> | |
582 | + <configuration> | |
583 | + <file>${project.build.directory}/${pkg.name}.deb</file> | |
584 | + <artifactId>${project.artifactId}</artifactId> | |
585 | + <groupId>${project.groupId}</groupId> | |
586 | + <version>${project.version}</version> | |
587 | + <classifier>deb</classifier> | |
588 | + <packaging>deb</packaging> | |
589 | + </configuration> | |
590 | + <executions> | |
591 | + <execution> | |
592 | + <id>install-deb</id> | |
593 | + <phase>package</phase> | |
594 | + <goals> | |
595 | + <goal>install-file</goal> | |
596 | + </goals> | |
597 | + </execution> | |
598 | + </executions> | |
599 | + </plugin> | |
600 | + <plugin> | |
580 | 601 | <groupId>org.xolstice.maven.plugins</groupId> |
581 | 602 | <artifactId>protobuf-maven-plugin</artifactId> |
582 | 603 | </plugin> | ... | ... |
... | ... | @@ -407,7 +407,7 @@ state: |
407 | 407 | |
408 | 408 | kafka: |
409 | 409 | enabled: true |
410 | - bootstrap.servers: "${TB_KAFKA_SERVERS:192.168.2.157:9092}" | |
410 | + bootstrap.servers: "${TB_KAFKA_SERVERS:localhost:9092}" | |
411 | 411 | acks: "${TB_KAFKA_ACKS:all}" |
412 | 412 | retries: "${TB_KAFKA_RETRIES:1}" |
413 | 413 | batch.size: "${TB_KAFKA_BATCH_SIZE:16384}" |
... | ... | @@ -415,7 +415,7 @@ kafka: |
415 | 415 | buffer.memory: "${TB_BUFFER_MEMORY:33554432}" |
416 | 416 | |
417 | 417 | js: |
418 | - evaluator: "${JS_EVALUATOR:remote}" # local/remote | |
418 | + evaluator: "${JS_EVALUATOR:local}" # local/remote | |
419 | 419 | # Built-in JVM JavaScript environment properties |
420 | 420 | local: |
421 | 421 | # Use Sandboxed (secured) JVM JavaScript environment | ... | ... |
... | ... | @@ -32,15 +32,8 @@ public class TBKafkaAdmin { |
32 | 32 | |
33 | 33 | AdminClient client; |
34 | 34 | |
35 | - public TBKafkaAdmin() { | |
36 | - Properties props = new Properties(); | |
37 | - props.put("bootstrap.servers", "localhost:9092"); | |
38 | - props.put("group.id", "test"); | |
39 | - props.put("enable.auto.commit", "true"); | |
40 | - props.put("auto.commit.interval.ms", "1000"); | |
41 | - props.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer"); | |
42 | - props.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer"); | |
43 | - client = AdminClient.create(props); | |
35 | + public TBKafkaAdmin(TbKafkaSettings settings) { | |
36 | + client = AdminClient.create(settings.toProps()); | |
44 | 37 | } |
45 | 38 | |
46 | 39 | public CreateTopicsResult createTopic(NewTopic topic){ | ... | ... |
... | ... | @@ -52,12 +52,16 @@ public class TBKafkaProducerTemplate<T> { |
52 | 52 | @Getter |
53 | 53 | private final String defaultTopic; |
54 | 54 | |
55 | + @Getter | |
56 | + private final TbKafkaSettings settings; | |
57 | + | |
55 | 58 | @Builder |
56 | 59 | private TBKafkaProducerTemplate(TbKafkaSettings settings, TbKafkaEncoder<T> encoder, TbKafkaEnricher<T> enricher, |
57 | 60 | TbKafkaPartitioner<T> partitioner, String defaultTopic) { |
58 | 61 | Properties props = settings.toProps(); |
59 | 62 | props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringSerializer"); |
60 | 63 | props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.ByteArraySerializer"); |
64 | + this.settings = settings; | |
61 | 65 | this.producer = new KafkaProducer<>(props); |
62 | 66 | this.encoder = encoder; |
63 | 67 | this.enricher = enricher; |
... | ... | @@ -67,7 +71,7 @@ public class TBKafkaProducerTemplate<T> { |
67 | 71 | |
68 | 72 | public void init() { |
69 | 73 | try { |
70 | - TBKafkaAdmin admin = new TBKafkaAdmin(); | |
74 | + TBKafkaAdmin admin = new TBKafkaAdmin(this.settings); | |
71 | 75 | CreateTopicsResult result = admin.createTopic(new NewTopic(defaultTopic, 100, (short) 1)); |
72 | 76 | result.all().get(); |
73 | 77 | } catch (Exception e) { | ... | ... |
... | ... | @@ -55,7 +55,8 @@ public class TbKafkaRequestTemplate<Request, Response> { |
55 | 55 | private volatile boolean stopped = false; |
56 | 56 | |
57 | 57 | @Builder |
58 | - public TbKafkaRequestTemplate(TBKafkaProducerTemplate<Request> requestTemplate, TBKafkaConsumerTemplate<Response> responseTemplate, | |
58 | + public TbKafkaRequestTemplate(TBKafkaProducerTemplate<Request> requestTemplate, | |
59 | + TBKafkaConsumerTemplate<Response> responseTemplate, | |
59 | 60 | long maxRequestTimeout, |
60 | 61 | long maxPendingRequests, |
61 | 62 | long pollInterval, |
... | ... | @@ -77,7 +78,7 @@ public class TbKafkaRequestTemplate<Request, Response> { |
77 | 78 | |
78 | 79 | public void init() { |
79 | 80 | try { |
80 | - TBKafkaAdmin admin = new TBKafkaAdmin(); | |
81 | + TBKafkaAdmin admin = new TBKafkaAdmin(this.requestTemplate.getSettings()); | |
81 | 82 | CreateTopicsResult result = admin.createTopic(new NewTopic(responseTemplate.getTopic(), 1, (short) 1)); |
82 | 83 | result.all().get(); |
83 | 84 | } catch (Exception e) { | ... | ... |
msa/docker/.env
0 → 100644
msa/docker/.gitignore
0 → 100644
... | ... | @@ -19,17 +19,19 @@ version: '2' |
19 | 19 | |
20 | 20 | services: |
21 | 21 | zookeeper: |
22 | + restart: always | |
22 | 23 | image: "wurstmeister/zookeeper" |
23 | 24 | ports: |
24 | 25 | - "2181" |
25 | 26 | kafka: |
27 | + restart: always | |
26 | 28 | image: "wurstmeister/kafka" |
27 | 29 | ports: |
28 | 30 | - "9092:9092" |
29 | 31 | environment: |
30 | 32 | KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 |
31 | 33 | KAFKA_LISTENERS: INSIDE://:9093,OUTSIDE://:9092 |
32 | - KAFKA_ADVERTISED_LISTENERS: INSIDE://:9093,OUTSIDE://${EXTERNAL_HOSTNAME}:9092 | |
34 | + KAFKA_ADVERTISED_LISTENERS: INSIDE://:9093,OUTSIDE://kafka:9092 | |
33 | 35 | KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INSIDE:PLAINTEXT,OUTSIDE:PLAINTEXT |
34 | 36 | KAFKA_INTER_BROKER_LISTENER_NAME: INSIDE |
35 | 37 | KAFKA_CREATE_TOPICS: "${KAFKA_TOPICS}" |
... | ... | @@ -37,21 +39,81 @@ services: |
37 | 39 | depends_on: |
38 | 40 | - zookeeper |
39 | 41 | tb-js-executor: |
40 | - image: "local-maven-build/tb-js-executor:latest" | |
42 | + restart: always | |
43 | + image: "${DOCKER_REPO}/tb-js-executor:${TB_VERSION}" | |
41 | 44 | environment: |
42 | 45 | TB_KAFKA_SERVERS: kafka:9092 |
43 | 46 | env_file: |
44 | 47 | - tb-js-executor.env |
45 | 48 | depends_on: |
46 | 49 | - kafka |
47 | - tb-web-ui: | |
48 | - image: "local-maven-build/tb-web-ui:latest" | |
50 | + tb: | |
51 | + restart: always | |
52 | + image: "${DOCKER_REPO}/tb-node:${TB_VERSION}" | |
49 | 53 | ports: |
50 | - - "8090:8090" | |
54 | + - "8080" | |
55 | + - "1883:1883" | |
56 | + - "5683:5683/udp" | |
57 | + env_file: | |
58 | + - tb-node.env | |
59 | + environment: | |
60 | + ZOOKEEPER_URL: zk:2181 | |
61 | + TB_KAFKA_SERVERS: kafka:9092 | |
62 | + JS_EVALUATOR: remote | |
63 | + volumes: | |
64 | + - ./tb-node/db:/usr/share/thingsboard/data/db" | |
65 | + - ./tb-node/conf:/config | |
66 | + - ./tb-node/log:/var/log/thingsboard | |
67 | + depends_on: | |
68 | + - kafka | |
69 | + tb-web-ui1: | |
70 | + restart: always | |
71 | + image: "${DOCKER_REPO}/tb-web-ui:${TB_VERSION}" | |
72 | + ports: | |
73 | + - "8080" | |
74 | + environment: | |
75 | + TB_HOST: tb | |
76 | + TB_PORT: 8080 | |
77 | + env_file: | |
78 | + - tb-web-ui.env | |
79 | + tb-web-ui2: | |
80 | + restart: always | |
81 | + image: "${DOCKER_REPO}/tb-web-ui:${TB_VERSION}" | |
82 | + ports: | |
83 | + - "8080" | |
51 | 84 | environment: |
52 | - HTTP_BIND_ADDRESS: 0.0.0.0 | |
53 | - HTTP_BIND_PORT: 8090 | |
54 | - TB_HOST: ${EXTERNAL_HOSTNAME} | |
85 | + TB_HOST: tb | |
55 | 86 | TB_PORT: 8080 |
56 | 87 | env_file: |
57 | 88 | - tb-web-ui.env |
89 | + tb-web-ui3: | |
90 | + restart: always | |
91 | + image: "${DOCKER_REPO}/tb-web-ui:${TB_VERSION}" | |
92 | + ports: | |
93 | + - "8080" | |
94 | + environment: | |
95 | + TB_HOST: tb | |
96 | + TB_PORT: 8080 | |
97 | + env_file: | |
98 | + - tb-web-ui.env | |
99 | + web: | |
100 | + restart: always | |
101 | + container_name: haproxy-certbot | |
102 | + image: nmarus/haproxy-certbot | |
103 | + volumes: | |
104 | + - ./haproxy/config:/config | |
105 | + - ./haproxy/letsencrypt:/etc/letsencrypt | |
106 | + - ./haproxy/certs.d:/usr/local/etc/haproxy/certs.d | |
107 | + ports: | |
108 | + - "80:80" | |
109 | + - "443:443" | |
110 | + - "9999:9999" | |
111 | + cap_add: | |
112 | + - NET_ADMIN | |
113 | + environment: | |
114 | + HTTP_PORT: ${HTTP_PORT} | |
115 | + HTTPS_PORT: ${HTTPS_PORT} | |
116 | + links: | |
117 | + - tb-web-ui1 | |
118 | + - tb-web-ui2 | |
119 | + - tb-web-ui3 | ... | ... |
msa/docker/docker-install-tb.sh
0 → 100755
1 | +#!/bin/bash | |
2 | +# | |
3 | +# Copyright © 2016-2018 The Thingsboard Authors | |
4 | +# | |
5 | +# Licensed under the Apache License, Version 2.0 (the "License"); | |
6 | +# you may not use this file except in compliance with the License. | |
7 | +# You may obtain a copy of the License at | |
8 | +# | |
9 | +# http://www.apache.org/licenses/LICENSE-2.0 | |
10 | +# | |
11 | +# Unless required by applicable law or agreed to in writing, software | |
12 | +# distributed under the License is distributed on an "AS IS" BASIS, | |
13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 | +# See the License for the specific language governing permissions and | |
15 | +# limitations under the License. | |
16 | +# | |
17 | + | |
18 | +while [[ $# -gt 0 ]] | |
19 | +do | |
20 | +key="$1" | |
21 | + | |
22 | +case $key in | |
23 | + --loadDemo) | |
24 | + LOAD_DEMO=true | |
25 | + shift # past argument | |
26 | + ;; | |
27 | + *) | |
28 | + # unknown option | |
29 | + ;; | |
30 | +esac | |
31 | +shift # past argument or value | |
32 | +done | |
33 | + | |
34 | +if [ "$LOAD_DEMO" == "true" ]; then | |
35 | + loadDemo=true | |
36 | +else | |
37 | + loadDemo=false | |
38 | +fi | |
39 | + | |
40 | +docker-compose run --rm -e INSTALL_TB=true -e LOAD_DEMO=${loadDemo} tb | |
41 | + | |
42 | + | ... | ... |
msa/docker/docker-start-services.sh
0 → 100755
1 | +#!/bin/bash | |
2 | +# | |
3 | +# Copyright © 2016-2018 The Thingsboard Authors | |
4 | +# | |
5 | +# Licensed under the Apache License, Version 2.0 (the "License"); | |
6 | +# you may not use this file except in compliance with the License. | |
7 | +# You may obtain a copy of the License at | |
8 | +# | |
9 | +# http://www.apache.org/licenses/LICENSE-2.0 | |
10 | +# | |
11 | +# Unless required by applicable law or agreed to in writing, software | |
12 | +# distributed under the License is distributed on an "AS IS" BASIS, | |
13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 | +# See the License for the specific language governing permissions and | |
15 | +# limitations under the License. | |
16 | +# | |
17 | + | |
18 | +docker-compose up -d | ... | ... |
msa/docker/docker-stop-services.sh
0 → 100755
1 | +#!/bin/bash | |
2 | +# | |
3 | +# Copyright © 2016-2018 The Thingsboard Authors | |
4 | +# | |
5 | +# Licensed under the Apache License, Version 2.0 (the "License"); | |
6 | +# you may not use this file except in compliance with the License. | |
7 | +# You may obtain a copy of the License at | |
8 | +# | |
9 | +# http://www.apache.org/licenses/LICENSE-2.0 | |
10 | +# | |
11 | +# Unless required by applicable law or agreed to in writing, software | |
12 | +# distributed under the License is distributed on an "AS IS" BASIS, | |
13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 | +# See the License for the specific language governing permissions and | |
15 | +# limitations under the License. | |
16 | +# | |
17 | + | |
18 | +docker-compose down | ... | ... |
msa/docker/docker-upgrade-tb.sh
0 → 100755
1 | +#!/bin/bash | |
2 | +# | |
3 | +# Copyright © 2016-2018 The Thingsboard Authors | |
4 | +# | |
5 | +# Licensed under the Apache License, Version 2.0 (the "License"); | |
6 | +# you may not use this file except in compliance with the License. | |
7 | +# You may obtain a copy of the License at | |
8 | +# | |
9 | +# http://www.apache.org/licenses/LICENSE-2.0 | |
10 | +# | |
11 | +# Unless required by applicable law or agreed to in writing, software | |
12 | +# distributed under the License is distributed on an "AS IS" BASIS, | |
13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 | +# See the License for the specific language governing permissions and | |
15 | +# limitations under the License. | |
16 | +# | |
17 | + | |
18 | +for i in "$@" | |
19 | +do | |
20 | +case $i in | |
21 | + --fromVersion=*) | |
22 | + FROM_VERSION="${i#*=}" | |
23 | + shift | |
24 | + ;; | |
25 | + *) | |
26 | + # unknown option | |
27 | + ;; | |
28 | +esac | |
29 | +done | |
30 | + | |
31 | +if [[ -z "${FROM_VERSION// }" ]]; then | |
32 | + echo "--fromVersion parameter is invalid or unspecified!" | |
33 | + echo "Usage: docker-upgrade-tb.sh --fromVersion={VERSION}" | |
34 | + exit 1 | |
35 | +else | |
36 | + fromVersion="${FROM_VERSION// }" | |
37 | +fi | |
38 | + | |
39 | +docker-compose run --rm -e UPGRADE_TB=true -e FROM_VERSION=${fromVersion} tb | ... | ... |
msa/docker/haproxy/certs.d/.gitignore
0 → 100644
msa/docker/haproxy/config/haproxy.cfg
0 → 100644
1 | +#HA Proxy Config | |
2 | +global | |
3 | + maxconn 4096 | |
4 | + | |
5 | + log 127.0.0.1 local0 | |
6 | + log 127.0.0.1 local1 notice | |
7 | + | |
8 | + ca-base /etc/ssl/certs | |
9 | + crt-base /etc/ssl/private | |
10 | + | |
11 | + 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 | |
12 | + ssl-default-bind-options no-sslv3 | |
13 | + | |
14 | +defaults | |
15 | + | |
16 | + option forwardfor | |
17 | + | |
18 | + log global | |
19 | + | |
20 | + mode http | |
21 | + | |
22 | + timeout connect 5000ms | |
23 | + timeout client 50000ms | |
24 | + timeout server 50000ms | |
25 | + | |
26 | +listen stats | |
27 | + bind *:9999 | |
28 | + stats enable | |
29 | + stats hide-version | |
30 | + stats uri /stats | |
31 | + stats auth admin:admin@123 | |
32 | + | |
33 | +frontend http-in | |
34 | + bind *:${HTTP_PORT} | |
35 | + | |
36 | + reqadd X-Forwarded-Proto:\ http | |
37 | + | |
38 | + acl letsencrypt_http_acl path_beg /.well-known/acme-challenge/ | |
39 | + redirect scheme https if !letsencrypt_http_acl | |
40 | + use_backend letsencrypt_http if letsencrypt_http_acl | |
41 | + | |
42 | + default_backend tb-web-backend | |
43 | + | |
44 | +frontend https_in | |
45 | + 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 | |
46 | + | |
47 | + reqadd X-Forwarded-Proto:\ https | |
48 | + | |
49 | + default_backend tb-web-backend | |
50 | + | |
51 | +backend letsencrypt_http | |
52 | + server letsencrypt_http_srv 127.0.0.1:8080 | |
53 | + | |
54 | +backend tb-web-backend | |
55 | + balance leastconn | |
56 | + option tcp-check | |
57 | + option log-health-checks | |
58 | + server tbWeb1 tb-web-ui1:8080 check | |
59 | + server tbWeb2 tb-web-ui2:8080 check | |
60 | + server tbWeb3 tb-web-ui3:8080 check | |
61 | + http-request set-header X-Forwarded-Port %[dst_port] | ... | ... |
msa/docker/haproxy/letsencrypt/.gitignore
0 → 100644
msa/docker/tb-node.env
0 → 100644
1 | +# ThingsBoard server configuration | |
2 | +MQTT_BIND_ADDRESS=0.0.0.0 | |
3 | +MQTT_BIND_PORT=1883 | |
4 | +COAP_BIND_ADDRESS=0.0.0.0 | |
5 | +COAP_BIND_PORT=5683 | |
6 | + | |
7 | +# type of database to use: sql[DEFAULT] or cassandra | |
8 | +DATABASE_TYPE=sql | |
9 | +SQL_DATA_FOLDER=/usr/share/thingsboard/data/db | |
10 | + | |
11 | +# cassandra db config | |
12 | +CASSANDRA_URL=cassandra:9042 | |
13 | +CASSANDRA_HOST=cassandra | |
14 | +CASSANDRA_PORT=9042 | |
15 | + | |
16 | +# postgres db config | |
17 | +POSTGRES_HOST=postgres | |
18 | +POSTGRES_PORT=5432 | |
19 | +# SPRING_JPA_DATABASE_PLATFORM=org.hibernate.dialect.PostgreSQLDialect | |
20 | +# SPRING_DRIVER_CLASS_NAME=org.postgresql.Driver | |
21 | +# SPRING_DATASOURCE_URL=jdbc:postgresql://postgres:5432/thingsboard | |
22 | +# SPRING_DATASOURCE_USERNAME=postgres | |
23 | +# SPRING_DATASOURCE_PASSWORD=postgres | ... | ... |
msa/docker/tb-node/conf/logback.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8" ?> | |
2 | +<!-- | |
3 | + | |
4 | + Copyright © 2016-2018 The Thingsboard Authors | |
5 | + | |
6 | + Licensed under the Apache License, Version 2.0 (the "License"); | |
7 | + you may not use this file except in compliance with the License. | |
8 | + You may obtain a copy of the License at | |
9 | + | |
10 | + http://www.apache.org/licenses/LICENSE-2.0 | |
11 | + | |
12 | + Unless required by applicable law or agreed to in writing, software | |
13 | + distributed under the License is distributed on an "AS IS" BASIS, | |
14 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
15 | + See the License for the specific language governing permissions and | |
16 | + limitations under the License. | |
17 | + | |
18 | +--> | |
19 | +<!DOCTYPE configuration> | |
20 | +<configuration scan="true" scanPeriod="10 seconds"> | |
21 | + | |
22 | + <appender name="fileLogAppender" | |
23 | + class="ch.qos.logback.core.rolling.RollingFileAppender"> | |
24 | + <file>/var/log/thingsboard/thingsboard.log</file> | |
25 | + <rollingPolicy | |
26 | + class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> | |
27 | + <fileNamePattern>/var/log/thingsboard/thingsboard.%d{yyyy-MM-dd}.%i.log</fileNamePattern> | |
28 | + <maxFileSize>100MB</maxFileSize> | |
29 | + <maxHistory>30</maxHistory> | |
30 | + <totalSizeCap>3GB</totalSizeCap> | |
31 | + </rollingPolicy> | |
32 | + <encoder> | |
33 | + <pattern>%d{ISO8601} [%thread] %-5level %logger{36} - %msg%n</pattern> | |
34 | + </encoder> | |
35 | + </appender> | |
36 | + | |
37 | + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | |
38 | + <encoder> | |
39 | + <pattern>%d{ISO8601} [%thread] %-5level %logger{36} - %msg%n</pattern> | |
40 | + </encoder> | |
41 | + </appender> | |
42 | + | |
43 | + <logger name="org.thingsboard.server" level="INFO" /> | |
44 | + <logger name="akka" level="INFO" /> | |
45 | + | |
46 | + <root level="INFO"> | |
47 | + <appender-ref ref="fileLogAppender"/> | |
48 | + <appender-ref ref="STDOUT"/> | |
49 | + </root> | |
50 | + | |
51 | +</configuration> | |
\ No newline at end of file | ... | ... |
msa/docker/tb-node/conf/thingsboard.conf
0 → 100644
1 | +# | |
2 | +# Copyright © 2016-2018 The Thingsboard Authors | |
3 | +# | |
4 | +# Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | +# you may not use this file except in compliance with the License. | |
6 | +# You may obtain a copy of the License at | |
7 | +# | |
8 | +# http://www.apache.org/licenses/LICENSE-2.0 | |
9 | +# | |
10 | +# Unless required by applicable law or agreed to in writing, software | |
11 | +# distributed under the License is distributed on an "AS IS" BASIS, | |
12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | +# See the License for the specific language governing permissions and | |
14 | +# limitations under the License. | |
15 | +# | |
16 | + | |
17 | +export JAVA_OPTS="$JAVA_OPTS -Dplatform=deb -Dinstall.data_dir=/usr/share/thingsboard/data" | |
18 | +export JAVA_OPTS="$JAVA_OPTS -Xloggc:/var/log/thingsboard/gc.log -XX:+IgnoreUnrecognizedVMOptions -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCDetails -XX:+PrintGCDateStamps" | |
19 | +export JAVA_OPTS="$JAVA_OPTS -XX:+PrintHeapAtGC -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10" | |
20 | +export JAVA_OPTS="$JAVA_OPTS -XX:GCLogFileSize=10M -XX:-UseBiasedLocking -XX:+UseTLAB -XX:+ResizeTLAB -XX:+PerfDisableSharedMem -XX:+UseCondCardMark" | |
21 | +export JAVA_OPTS="$JAVA_OPTS -XX:CMSWaitDuration=10000 -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+CMSParallelInitialMarkEnabled" | |
22 | +export JAVA_OPTS="$JAVA_OPTS -XX:+CMSEdenChunksRecordAlways -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly" | |
23 | +export LOG_FILENAME=thingsboard.out | |
24 | +export LOADER_PATH=/usr/share/thingsboard/conf,/usr/share/thingsboard/extensions | ... | ... |
msa/docker/tb-node/db/.gitignore
0 → 100644
msa/docker/tb-node/log/.gitignore
0 → 100644
... | ... | @@ -40,7 +40,6 @@ |
40 | 40 | <pkg.installFolder>/usr/share/${pkg.name}</pkg.installFolder> |
41 | 41 | <pkg.linux.dist>${project.build.directory}/package/linux</pkg.linux.dist> |
42 | 42 | <pkg.win.dist>${project.build.directory}/package/windows</pkg.win.dist> |
43 | - <dockerfile.skip>true</dockerfile.skip> | |
44 | 43 | </properties> |
45 | 44 | |
46 | 45 | <dependencies> |
... | ... | @@ -280,7 +279,6 @@ |
280 | 279 | <plugin> |
281 | 280 | <groupId>com.spotify</groupId> |
282 | 281 | <artifactId>dockerfile-maven-plugin</artifactId> |
283 | - <version>1.4.4</version> | |
284 | 282 | <executions> |
285 | 283 | <execution> |
286 | 284 | <id>build-docker-image</id> |
... | ... | @@ -292,7 +290,8 @@ |
292 | 290 | </executions> |
293 | 291 | <configuration> |
294 | 292 | <skip>${dockerfile.skip}</skip> |
295 | - <repository>local-maven-build/${pkg.name}</repository> | |
293 | + <repository>${docker.repo}/${pkg.name}</repository> | |
294 | + <tag>${project.version}</tag> | |
296 | 295 | <verbose>true</verbose> |
297 | 296 | <googleContainerRegistryEnabled>false</googleContainerRegistryEnabled> |
298 | 297 | <contextDirectory>${project.build.directory}</contextDirectory> | ... | ... |
... | ... | @@ -32,11 +32,26 @@ |
32 | 32 | |
33 | 33 | <properties> |
34 | 34 | <main.dir>${basedir}/..</main.dir> |
35 | + <docker.repo>local-maven-build</docker.repo> | |
36 | + <dockerfile.skip>true</dockerfile.skip> | |
35 | 37 | </properties> |
36 | 38 | |
37 | 39 | <modules> |
38 | 40 | <module>js-executor</module> |
39 | 41 | <module>web-ui</module> |
42 | + <module>tb-node</module> | |
40 | 43 | </modules> |
41 | 44 | |
45 | + <build> | |
46 | + <pluginManagement> | |
47 | + <plugins> | |
48 | + <plugin> | |
49 | + <groupId>com.spotify</groupId> | |
50 | + <artifactId>dockerfile-maven-plugin</artifactId> | |
51 | + <version>1.4.5</version> | |
52 | + </plugin> | |
53 | + </plugins> | |
54 | + </pluginManagement> | |
55 | + </build> | |
56 | + | |
42 | 57 | </project> | ... | ... |
msa/tb-node/docker/Dockerfile
0 → 100644
1 | +# | |
2 | +# Copyright © 2016-2018 The Thingsboard Authors | |
3 | +# | |
4 | +# Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | +# you may not use this file except in compliance with the License. | |
6 | +# You may obtain a copy of the License at | |
7 | +# | |
8 | +# http://www.apache.org/licenses/LICENSE-2.0 | |
9 | +# | |
10 | +# Unless required by applicable law or agreed to in writing, software | |
11 | +# distributed under the License is distributed on an "AS IS" BASIS, | |
12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | +# See the License for the specific language governing permissions and | |
14 | +# limitations under the License. | |
15 | +# | |
16 | + | |
17 | +FROM openjdk:8-jre | |
18 | + | |
19 | +COPY start-tb-node.sh ${pkg.name}.deb /tmp/ | |
20 | + | |
21 | +RUN chmod a+x /tmp/*.sh \ | |
22 | + && mv /tmp/start-tb-node.sh /usr/bin | |
23 | + | |
24 | +RUN dpkg -i /tmp/${pkg.name}.deb | |
25 | + | |
26 | +RUN update-rc.d ${pkg.name} disable | |
27 | + | |
28 | +CMD ["start-tb-node.sh"] | ... | ... |
msa/tb-node/docker/start-tb-node.sh
0 → 100755
1 | +#!/bin/bash | |
2 | +# | |
3 | +# Copyright © 2016-2018 The Thingsboard Authors | |
4 | +# | |
5 | +# Licensed under the Apache License, Version 2.0 (the "License"); | |
6 | +# you may not use this file except in compliance with the License. | |
7 | +# You may obtain a copy of the License at | |
8 | +# | |
9 | +# http://www.apache.org/licenses/LICENSE-2.0 | |
10 | +# | |
11 | +# Unless required by applicable law or agreed to in writing, software | |
12 | +# distributed under the License is distributed on an "AS IS" BASIS, | |
13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 | +# See the License for the specific language governing permissions and | |
15 | +# limitations under the License. | |
16 | +# | |
17 | + | |
18 | +CONF_FOLDER="/config" | |
19 | +jarfile=${pkg.installFolder}/bin/${pkg.name}.jar | |
20 | +configfile=${pkg.name}.conf | |
21 | +run_user=${pkg.name} | |
22 | + | |
23 | +source "${CONF_FOLDER}/${configfile}" | |
24 | + | |
25 | +export LOADER_PATH=/config,${LOADER_PATH} | |
26 | + | |
27 | +if [ "$INSTALL_TB" == "true" ]; then | |
28 | + | |
29 | + if [ "$LOAD_DEMO" == "true" ]; then | |
30 | + loadDemo=true | |
31 | + else | |
32 | + loadDemo=false | |
33 | + fi | |
34 | + | |
35 | + echo "Starting ThingsBoard installation ..." | |
36 | + | |
37 | + exec java -cp ${jarfile} $JAVA_OPTS -Dloader.main=org.thingsboard.server.ThingsboardInstallApplication \ | |
38 | + -Dinstall.load_demo=${loadDemo} \ | |
39 | + -Dspring.jpa.hibernate.ddl-auto=none \ | |
40 | + -Dinstall.upgrade=false \ | |
41 | + -Dlogging.config=/usr/share/thingsboard/bin/install/logback.xml \ | |
42 | + org.springframework.boot.loader.PropertiesLauncher | |
43 | + | |
44 | +elif [ "$UPGRADE_TB" == "true" ]; then | |
45 | + | |
46 | + echo "Starting ThingsBoard upgrade ..." | |
47 | + | |
48 | + if [[ -z "${FROM_VERSION// }" ]]; then | |
49 | + echo "FROM_VERSION variable is invalid or unspecified!" | |
50 | + exit 1 | |
51 | + else | |
52 | + fromVersion="${FROM_VERSION// }" | |
53 | + fi | |
54 | + | |
55 | + exec java -cp ${jarfile} $JAVA_OPTS -Dloader.main=org.thingsboard.server.ThingsboardInstallApplication \ | |
56 | + -Dspring.jpa.hibernate.ddl-auto=none \ | |
57 | + -Dinstall.upgrade=true \ | |
58 | + -Dinstall.upgrade.from_version=${fromVersion} \ | |
59 | + -Dlogging.config=/usr/share/thingsboard/bin/install/logback.xml \ | |
60 | + org.springframework.boot.loader.PropertiesLauncher | |
61 | + | |
62 | +else | |
63 | + | |
64 | + echo "Starting '${project.name}' ..." | |
65 | + | |
66 | + exec java -cp ${jarfile} $JAVA_OPTS -Dloader.main=org.thingsboard.server.ThingsboardServerApplication \ | |
67 | + -Dspring.jpa.hibernate.ddl-auto=none \ | |
68 | + -Dlogging.config=/config/logback.xml \ | |
69 | + org.springframework.boot.loader.PropertiesLauncher | |
70 | + | |
71 | +fi | ... | ... |
msa/tb-node/pom.xml
0 → 100644
1 | +<!-- | |
2 | + | |
3 | + Copyright © 2016-2018 The Thingsboard Authors | |
4 | + | |
5 | + Licensed under the Apache License, Version 2.0 (the "License"); | |
6 | + you may not use this file except in compliance with the License. | |
7 | + You may obtain a copy of the License at | |
8 | + | |
9 | + http://www.apache.org/licenses/LICENSE-2.0 | |
10 | + | |
11 | + Unless required by applicable law or agreed to in writing, software | |
12 | + distributed under the License is distributed on an "AS IS" BASIS, | |
13 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 | + See the License for the specific language governing permissions and | |
15 | + limitations under the License. | |
16 | + | |
17 | +--> | |
18 | +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
19 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
20 | + <modelVersion>4.0.0</modelVersion> | |
21 | + <parent> | |
22 | + <groupId>org.thingsboard</groupId> | |
23 | + <version>2.2.0-SNAPSHOT</version> | |
24 | + <artifactId>msa</artifactId> | |
25 | + </parent> | |
26 | + <groupId>org.thingsboard.msa</groupId> | |
27 | + <artifactId>tb-node</artifactId> | |
28 | + <packaging>pom</packaging> | |
29 | + | |
30 | + <name>ThingsBoard Node Microservice</name> | |
31 | + <url>https://thingsboard.io</url> | |
32 | + <description>ThingsBoard Node Microservice</description> | |
33 | + | |
34 | + <properties> | |
35 | + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | |
36 | + <main.dir>${basedir}/../..</main.dir> | |
37 | + <pkg.name>thingsboard</pkg.name> | |
38 | + <pkg.user>thingsboard</pkg.user> | |
39 | + <pkg.unixLogFolder>/var/log/${pkg.name}</pkg.unixLogFolder> | |
40 | + <pkg.installFolder>/usr/share/${pkg.name}</pkg.installFolder> | |
41 | + </properties> | |
42 | + | |
43 | + <dependencies> | |
44 | + <dependency> | |
45 | + <groupId>org.thingsboard</groupId> | |
46 | + <artifactId>application</artifactId> | |
47 | + <version>${project.version}</version> | |
48 | + <classifier>deb</classifier> | |
49 | + <type>deb</type> | |
50 | + <scope>provided</scope> | |
51 | + </dependency> | |
52 | + </dependencies> | |
53 | + | |
54 | + <build> | |
55 | + <plugins> | |
56 | + <plugin> | |
57 | + <groupId>org.apache.maven.plugins</groupId> | |
58 | + <artifactId>maven-dependency-plugin</artifactId> | |
59 | + <executions> | |
60 | + <execution> | |
61 | + <id>copy-tb-deb</id> | |
62 | + <phase>package</phase> | |
63 | + <goals> | |
64 | + <goal>copy</goal> | |
65 | + </goals> | |
66 | + <configuration> | |
67 | + <artifactItems> | |
68 | + <artifactItem> | |
69 | + <groupId>org.thingsboard</groupId> | |
70 | + <artifactId>application</artifactId> | |
71 | + <classifier>deb</classifier> | |
72 | + <type>deb</type> | |
73 | + <destFileName>${pkg.name}.deb</destFileName> | |
74 | + <outputDirectory>${project.build.directory}</outputDirectory> | |
75 | + </artifactItem> | |
76 | + </artifactItems> | |
77 | + </configuration> | |
78 | + </execution> | |
79 | + </executions> | |
80 | + </plugin> | |
81 | + <plugin> | |
82 | + <groupId>org.apache.maven.plugins</groupId> | |
83 | + <artifactId>maven-resources-plugin</artifactId> | |
84 | + <executions> | |
85 | + <execution> | |
86 | + <id>copy-docker-config</id> | |
87 | + <phase>process-resources</phase> | |
88 | + <goals> | |
89 | + <goal>copy-resources</goal> | |
90 | + </goals> | |
91 | + <configuration> | |
92 | + <outputDirectory>${project.build.directory}</outputDirectory> | |
93 | + <resources> | |
94 | + <resource> | |
95 | + <directory>docker</directory> | |
96 | + <filtering>true</filtering> | |
97 | + </resource> | |
98 | + </resources> | |
99 | + </configuration> | |
100 | + </execution> | |
101 | + </executions> | |
102 | + </plugin> | |
103 | + <plugin> | |
104 | + <groupId>com.spotify</groupId> | |
105 | + <artifactId>dockerfile-maven-plugin</artifactId> | |
106 | + <executions> | |
107 | + <execution> | |
108 | + <id>build-docker-image</id> | |
109 | + <phase>pre-integration-test</phase> | |
110 | + <goals> | |
111 | + <goal>build</goal> | |
112 | + </goals> | |
113 | + </execution> | |
114 | + </executions> | |
115 | + <configuration> | |
116 | + <skip>${dockerfile.skip}</skip> | |
117 | + <repository>${docker.repo}/tb-node</repository> | |
118 | + <tag>${project.version}</tag> | |
119 | + <verbose>true</verbose> | |
120 | + <googleContainerRegistryEnabled>false</googleContainerRegistryEnabled> | |
121 | + <contextDirectory>${project.build.directory}</contextDirectory> | |
122 | + </configuration> | |
123 | + </plugin> | |
124 | + </plugins> | |
125 | + </build> | |
126 | + <repositories> | |
127 | + <repository> | |
128 | + <id>jenkins</id> | |
129 | + <name>Jenkins Repository</name> | |
130 | + <url>http://repo.jenkins-ci.org/releases</url> | |
131 | + <snapshots> | |
132 | + <enabled>false</enabled> | |
133 | + </snapshots> | |
134 | + </repository> | |
135 | + </repositories> | |
136 | +</project> | ... | ... |
... | ... | @@ -40,7 +40,6 @@ |
40 | 40 | <pkg.installFolder>/usr/share/${pkg.name}</pkg.installFolder> |
41 | 41 | <pkg.linux.dist>${project.build.directory}/package/linux</pkg.linux.dist> |
42 | 42 | <pkg.win.dist>${project.build.directory}/package/windows</pkg.win.dist> |
43 | - <dockerfile.skip>true</dockerfile.skip> | |
44 | 43 | </properties> |
45 | 44 | |
46 | 45 | <dependencies> |
... | ... | @@ -304,7 +303,6 @@ |
304 | 303 | <plugin> |
305 | 304 | <groupId>com.spotify</groupId> |
306 | 305 | <artifactId>dockerfile-maven-plugin</artifactId> |
307 | - <version>1.4.4</version> | |
308 | 306 | <executions> |
309 | 307 | <execution> |
310 | 308 | <id>build-docker-image</id> |
... | ... | @@ -316,7 +314,8 @@ |
316 | 314 | </executions> |
317 | 315 | <configuration> |
318 | 316 | <skip>${dockerfile.skip}</skip> |
319 | - <repository>local-maven-build/${pkg.name}</repository> | |
317 | + <repository>${docker.repo}/${pkg.name}</repository> | |
318 | + <tag>${project.version}</tag> | |
320 | 319 | <verbose>true</verbose> |
321 | 320 | <googleContainerRegistryEnabled>false</googleContainerRegistryEnabled> |
322 | 321 | <contextDirectory>${project.build.directory}</contextDirectory> | ... | ... |
... | ... | @@ -284,6 +284,8 @@ |
284 | 284 | <exclude>src/main/scripts/windows/**</exclude> |
285 | 285 | <exclude>src/main/resources/public/static/rulenode/**</exclude> |
286 | 286 | <exclude>**/*.proto.js</exclude> |
287 | + <exclude>docker/haproxy/**</exclude> | |
288 | + <exclude>docker/tb-node/**</exclude> | |
287 | 289 | </excludes> |
288 | 290 | <mapping> |
289 | 291 | <proto>JAVADOC_STYLE</proto> | ... | ... |