Commit 49feb9132ca8877efbc719beff76d951cabdfe26
1 parent
f87e5d66
Docker updates to new release features
Showing
17 changed files
with
58 additions
and
273 deletions
@@ -233,7 +233,7 @@ spring: | @@ -233,7 +233,7 @@ spring: | ||
233 | jpa: | 233 | jpa: |
234 | hibernate: | 234 | hibernate: |
235 | ddl-auto: "validate" | 235 | ddl-auto: "validate" |
236 | - database-platform: "org.hibernate.dialect.HSQLDialect" | 236 | + database-platform: "${SPRING_JPA_DATABASE_PLATFORM:org.hibernate.dialect.HSQLDialect}" |
237 | datasource: | 237 | datasource: |
238 | driverClassName: "${SPRING_DRIVER_CLASS_NAME:org.hsqldb.jdbc.JDBCDriver}" | 238 | driverClassName: "${SPRING_DRIVER_CLASS_NAME:org.hsqldb.jdbc.JDBCDriver}" |
239 | url: "${SPRING_DATASOURCE_URL:jdbc:hsqldb:file:${SQL_DATA_FOLDER:/tmp}/thingsboardDb;sql.enforce_size=false}" | 239 | url: "${SPRING_DATASOURCE_URL:jdbc:hsqldb:file:${SQL_DATA_FOLDER:/tmp}/thingsboardDb;sql.enforce_size=false}" |
@@ -250,7 +250,7 @@ spring: | @@ -250,7 +250,7 @@ spring: | ||
250 | # jpa: | 250 | # jpa: |
251 | # hibernate: | 251 | # hibernate: |
252 | # ddl-auto: "validate" | 252 | # ddl-auto: "validate" |
253 | -# database-platform: "org.hibernate.dialect.PostgreSQLDialect" | 253 | +# database-platform: "${SPRING_JPA_DATABASE_PLATFORM:org.hibernate.dialect.PostgreSQLDialect}" |
254 | # datasource: | 254 | # datasource: |
255 | # driverClassName: "${SPRING_DRIVER_CLASS_NAME:org.postgresql.Driver}" | 255 | # driverClassName: "${SPRING_DRIVER_CLASS_NAME:org.postgresql.Driver}" |
256 | # url: "${SPRING_DATASOURCE_URL:jdbc:postgresql://localhost:5432/thingsboard}" | 256 | # url: "${SPRING_DATASOURCE_URL:jdbc:postgresql://localhost:5432/thingsboard}" |
1 | # cassandra environment variables | 1 | # cassandra environment variables |
2 | CASSANDRA_DATA_DIR=/home/docker/cassandra_volume | 2 | CASSANDRA_DATA_DIR=/home/docker/cassandra_volume |
3 | -CASSANDRA_URL=cassandra | ||
4 | 3 | ||
5 | # postgres environment variables | 4 | # postgres environment variables |
6 | POSTGRES_DATA_DIR=/home/docker/postgres_volume | 5 | POSTGRES_DATA_DIR=/home/docker/postgres_volume |
7 | POSTGRES_DB=thingsboard | 6 | POSTGRES_DB=thingsboard |
8 | -POSTGRES_USER=postgres | ||
9 | -POSTGRES_PASSWORD=postgres | ||
10 | -POSTGRES_URL=postgres | 7 | + |
8 | +# hsqldb environment variables | ||
9 | +HSQLDB_DATA_DIR=/home/docker/hsqldb_volume | ||
11 | 10 | ||
12 | # environment variables for schema init and insert system and demo data | 11 | # environment variables for schema init and insert system and demo data |
13 | -CREATE_SCHEMA=true | ||
14 | -ADD_SYSTEM_DATA=false | 12 | +ADD_SCHEMA_AND_SYSTEM_DATA=false |
15 | ADD_DEMO_DATA=false | 13 | ADD_DEMO_DATA=false |
@@ -25,15 +25,12 @@ services: | @@ -25,15 +25,12 @@ services: | ||
25 | - "5683:5683/udp" | 25 | - "5683:5683/udp" |
26 | env_file: | 26 | env_file: |
27 | - tb.env | 27 | - tb.env |
28 | - entrypoint: /run-application.sh | ||
29 | - tb-cassandra-schema: | ||
30 | - image: "thingsboard/tb-cassandra-schema:1.2.4" | ||
31 | environment: | 28 | environment: |
32 | - - CREATE_SCHEMA=${CREATE_SCHEMA} | ||
33 | - - ADD_SYSTEM_DATA=${ADD_SYSTEM_DATA} | 29 | + - ADD_SCHEMA_AND_SYSTEM_DATA=${ADD_SCHEMA_AND_SYSTEM_DATA} |
34 | - ADD_DEMO_DATA=${ADD_DEMO_DATA} | 30 | - ADD_DEMO_DATA=${ADD_DEMO_DATA} |
35 | - - CASSANDRA_URL=${CASSANDRA_URL} | ||
36 | - entrypoint: /install-schema.sh | 31 | + volumes: |
32 | + - "${HSQLDB_DATA_DIR}:/usr/share/thingsboard/data/sql" | ||
33 | + entrypoint: /run-application.sh | ||
37 | cassandra: | 34 | cassandra: |
38 | image: "cassandra:3.9" | 35 | image: "cassandra:3.9" |
39 | ports: | 36 | ports: |
@@ -52,18 +49,5 @@ services: | @@ -52,18 +49,5 @@ services: | ||
52 | - "5432" | 49 | - "5432" |
53 | environment: | 50 | environment: |
54 | - POSTGRES_DB=${POSTGRES_DB} | 51 | - POSTGRES_DB=${POSTGRES_DB} |
55 | - - POSTGRES_USER=${POSTGRES_USER} | ||
56 | - - POSTGRES_PASSWORD=${POSTGRES_PASSWORD} | ||
57 | volumes: | 52 | volumes: |
58 | - "${POSTGRES_DATA_DIR}:/var/lib/postgresql/data" | 53 | - "${POSTGRES_DATA_DIR}:/var/lib/postgresql/data" |
59 | - tb-postgres-schema: | ||
60 | - image: "thingsboard/tb-postgres-schema:1.2.4" | ||
61 | - environment: | ||
62 | - - POSTGRES_URL=${POSTGRES_URL} | ||
63 | - - POSTGRES_DB=${POSTGRES_DB} | ||
64 | - - POSTGRES_USER=${POSTGRES_USER} | ||
65 | - - POSTGRES_PASSWORD=${POSTGRES_PASSWORD} | ||
66 | - - CREATE_SCHEMA=${CREATE_SCHEMA} | ||
67 | - - ADD_SYSTEM_DATA=${ADD_SYSTEM_DATA} | ||
68 | - - ADD_DEMO_DATA=${ADD_DEMO_DATA} | ||
69 | - entrypoint: /install-schema.sh |
docker/k8s/cassandra.yaml
renamed from
docker/cassandra/cassandra.yaml
docker/k8s/common.yaml
renamed from
docker/common/common.yaml
docker/k8s/tb.yaml
renamed from
docker/tb/tb.yaml
docker/k8s/zookeeper.yaml
renamed from
docker/zookeeper/zookeeper.yaml
docker/tb-cassandra-schema/Dockerfile
deleted
100644 → 0
1 | -# | ||
2 | -# Copyright © 2016-2017 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 cassandra:3.9 | ||
18 | - | ||
19 | -ADD install-schema.sh /install-schema.sh | ||
20 | - | ||
21 | -RUN apt-get update \ | ||
22 | - && apt-get install -y nmap \ | ||
23 | - && chmod +x /install-schema.sh | ||
24 | - | ||
25 | -ADD schema.cql /schema.cql | ||
26 | -ADD demo-data.cql /demo-data.cql | ||
27 | -ADD system-data.cql /system-data.cql | ||
28 | - |
docker/tb-cassandra-schema/Makefile
deleted
100644 → 0
1 | -VERSION=1.2.4 | ||
2 | -PROJECT=thingsboard | ||
3 | -APP=tb-cassandra-schema | ||
4 | - | ||
5 | -build: | ||
6 | - cp ../../dao/src/main/resources/cassandra/schema.cql . | ||
7 | - cp ../../dao/src/main/resources/cassandra/demo-data.cql . | ||
8 | - cp ../../dao/src/main/resources/cassandra/system-data.cql . | ||
9 | - docker build --pull -t ${PROJECT}/${APP}:${VERSION} -t ${PROJECT}/${APP}:latest . | ||
10 | - rm schema.cql demo-data.cql system-data.cql | ||
11 | - | ||
12 | -push: build | ||
13 | - docker push ${PROJECT}/${APP}:${VERSION} | ||
14 | - docker push ${PROJECT}/${APP}:latest |
docker/tb-cassandra-schema/install-schema.sh
deleted
100644 → 0
1 | -#!/bin/bash | ||
2 | -# | ||
3 | -# Copyright © 2016-2017 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 | - | ||
19 | -until nmap $CASSANDRA_URL -p 9042 | grep "9042/tcp open" | ||
20 | -do | ||
21 | - echo "Wait for $CASSANDRA_URL..." | ||
22 | - sleep 10 | ||
23 | -done | ||
24 | - | ||
25 | -if [ "$CREATE_SCHEMA" == "true" ]; then | ||
26 | - echo "Creating 'Thingsboard' keyspace..." | ||
27 | - cqlsh $CASSANDRA_URL -f /schema.cql | ||
28 | - if [ "$?" -eq 0 ]; then | ||
29 | - echo "'Thingsboard' keyspace was successfully created!" | ||
30 | - else | ||
31 | - echo "There were issues while creating 'Thingsboard' keyspace!" | ||
32 | - fi | ||
33 | -fi | ||
34 | - | ||
35 | -if [ "$ADD_SYSTEM_DATA" == "true" ]; then | ||
36 | - echo "Adding system data..." | ||
37 | - cqlsh $CASSANDRA_URL -f /system-data.cql | ||
38 | - if [ "$?" -eq 0 ]; then | ||
39 | - echo "System data was successfully added!" | ||
40 | - else | ||
41 | - echo "There were issues while adding System data!" | ||
42 | - fi | ||
43 | -fi | ||
44 | - | ||
45 | -if [ "$ADD_DEMO_DATA" == "true" ]; then | ||
46 | - echo "Adding demo data..." | ||
47 | - cqlsh $CASSANDRA_URL -f /demo-data.cql | ||
48 | - if [ "$?" -eq 0 ]; then | ||
49 | - echo "Demo data was successfully added!" | ||
50 | - else | ||
51 | - echo "There were issues while adding Demo data!" | ||
52 | - fi | ||
53 | -fi |
docker/tb-cassandra-schema/tb-cassandra-schema.yaml
deleted
100644 → 0
1 | -# | ||
2 | -# Copyright © 2016-2017 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 | -apiVersion: v1 | ||
18 | -kind: Pod | ||
19 | -metadata: | ||
20 | - name: tb-cassandra-schema | ||
21 | -spec: | ||
22 | - containers: | ||
23 | - - name: tb-cassandra-schema | ||
24 | - imagePullPolicy: Always | ||
25 | - image: thingsboard/tb-cassandra-schema:1.2.4 | ||
26 | - env: | ||
27 | - - name: CREATE_SCHEMA | ||
28 | - value: "true" | ||
29 | - - name: ADD_SYSTEM_DATA | ||
30 | - value: "true" | ||
31 | - - name : ADD_DEMO_DATA | ||
32 | - value: "true" | ||
33 | - - name : CASSANDRA_URL | ||
34 | - value: "cassandra-headless" | ||
35 | - command: | ||
36 | - - sh | ||
37 | - - -c | ||
38 | - - /install-schema.sh | ||
39 | - restartPolicy: Never |
docker/tb-postgres-schema/Dockerfile
deleted
100644 → 0
1 | -# | ||
2 | -# Copyright © 2016-2017 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 postgres:9.6 | ||
18 | - | ||
19 | -ADD install-schema.sh /install-schema.sh | ||
20 | - | ||
21 | -RUN apt-get update \ | ||
22 | - && apt-get install -y nmap \ | ||
23 | - && chmod +x /install-schema.sh | ||
24 | - | ||
25 | -ADD schema.sql /schema.sql | ||
26 | -ADD system-data.sql /system-data.sql | ||
27 | -ADD demo-data.sql /demo-data.sql |
docker/tb-postgres-schema/Makefile
deleted
100644 → 0
1 | -VERSION=1.2.4 | ||
2 | -PROJECT=thingsboard | ||
3 | -APP=tb-postgres-schema | ||
4 | - | ||
5 | -build: | ||
6 | - cp ../../dao/src/main/resources/postgres/schema.sql . | ||
7 | - cp ../../dao/src/main/resources/postgres/demo-data.sql . | ||
8 | - cp ../../dao/src/main/resources/postgres/system-data.sql . | ||
9 | - docker build --pull -t ${PROJECT}/${APP}:${VERSION} -t ${PROJECT}/${APP}:latest . | ||
10 | - rm schema.sql demo-data.sql system-data.sql | ||
11 | - | ||
12 | -push: build | ||
13 | - docker push ${PROJECT}/${APP}:${VERSION} | ||
14 | - docker push ${PROJECT}/${APP}:latest |
docker/tb-postgres-schema/install-schema.sh
deleted
100644 → 0
1 | -#!/bin/bash | ||
2 | -# | ||
3 | -# Copyright © 2016-2017 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 | -until nmap $POSTGRES_URL -p 5432 | grep "5432/tcp open" | ||
19 | -do | ||
20 | - echo "Waiting for $POSTGRES_URL..." | ||
21 | - sleep 10 | ||
22 | -done | ||
23 | - | ||
24 | -if [ "$CREATE_SCHEMA" == "true" ]; then | ||
25 | - echo "Creating 'Thingsboard' database schema..." | ||
26 | - PGPASSWORD="$POSTGRES_PASSWORD" psql -h "$POSTGRES_URL" -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" -f /schema.sql | ||
27 | - if [ "$?" -eq 0 ]; then | ||
28 | - echo "'Thingsboard' database schema was successfully created!" | ||
29 | - else | ||
30 | - echo "There were issues while creating 'Thingsboard' database schema!" | ||
31 | - fi | ||
32 | -fi | ||
33 | - | ||
34 | -if [ "$ADD_SYSTEM_DATA" == "true" ]; then | ||
35 | - echo "Adding system data..." | ||
36 | - PGPASSWORD="$POSTGRES_PASSWORD" psql -h "$POSTGRES_URL" -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" -f /system-data.sql | ||
37 | - if [ "$?" -eq 0 ]; then | ||
38 | - echo "System data was successfully added!" | ||
39 | - else | ||
40 | - echo "There were issues while adding System data!" | ||
41 | - fi | ||
42 | -fi | ||
43 | - | ||
44 | -if [ "$ADD_DEMO_DATA" == "true" ]; then | ||
45 | - echo "Adding demo data..." | ||
46 | - PGPASSWORD="$POSTGRES_PASSWORD" psql -h "$POSTGRES_URL" -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" -f /demo-data.sql | ||
47 | - if [ "$?" -eq 0 ]; then | ||
48 | - echo "Demo data was successfully added!" | ||
49 | - else | ||
50 | - echo "There were issues while adding Demo data!" | ||
51 | - fi | ||
52 | -fi |
1 | #Thingsboard server configuration | 1 | #Thingsboard server configuration |
2 | - | ||
3 | -TB_CASSANDRA_SCHEMA_URL=tb-cassandra-schema | ||
4 | -CASSANDRA_URL=cassandra:9042 | ||
5 | -ZOOKEEPER_URL=zk:2181 | ||
6 | MQTT_BIND_ADDRESS=0.0.0.0 | 2 | MQTT_BIND_ADDRESS=0.0.0.0 |
7 | MQTT_BIND_PORT=1883 | 3 | MQTT_BIND_PORT=1883 |
8 | COAP_BIND_ADDRESS=0.0.0.0 | 4 | COAP_BIND_ADDRESS=0.0.0.0 |
9 | -COAP_BIND_PORT=5683 | ||
5 | +COAP_BIND_PORT=5683 | ||
6 | + | ||
7 | +# zk config | ||
8 | +ZOOKEEPER_URL=zk:2181 | ||
9 | + | ||
10 | +# type of database to use: sql[DEFAULT] or cassandra | ||
11 | +DATABASE_TYPE=sql | ||
12 | + | ||
13 | +# cassandra db config | ||
14 | +CASSANDRA_URL=cassandra:9042 | ||
15 | + | ||
16 | +# postgres db config | ||
17 | +# SPRING_JPA_DATABASE_PLATFORM=org.hibernate.dialect.PostgreSQLDialect | ||
18 | +# SPRING_DRIVER_CLASS_NAME=org.postgresql.Driver | ||
19 | +# SPRING_DATASOURCE_URL=jdbc:postgresql://postgres:5432/thingsboard | ||
20 | +# SPRING_DATASOURCE_USERNAME=postgres | ||
21 | +# SPRING_DATASOURCE_PASSWORD=postgres |
@@ -19,4 +19,6 @@ FROM openjdk:8-jre | @@ -19,4 +19,6 @@ FROM openjdk:8-jre | ||
19 | ADD run-application.sh /run-application.sh | 19 | ADD run-application.sh /run-application.sh |
20 | ADD thingsboard.deb /thingsboard.deb | 20 | ADD thingsboard.deb /thingsboard.deb |
21 | 21 | ||
22 | -RUN chmod +x /run-application.sh | 22 | +RUN apt-get update \ |
23 | + && apt-get install -y nmap \ | ||
24 | + && chmod +x /run-application.sh |
@@ -18,18 +18,34 @@ | @@ -18,18 +18,34 @@ | ||
18 | 18 | ||
19 | dpkg -i /thingsboard.deb | 19 | dpkg -i /thingsboard.deb |
20 | 20 | ||
21 | -reachable=0 | ||
22 | -while [ $reachable -eq 0 ]; | ||
23 | -do | ||
24 | - echo "$TB_CASSANDRA_SCHEMA_URL container is still in progress. waiting until it completed..." | ||
25 | - sleep 3 | ||
26 | - ping -q -c 1 $TB_CASSANDRA_SCHEMA_URL > /dev/null 2>&1 | ||
27 | - if [ "$?" -ne 0 ]; | ||
28 | - then | ||
29 | - echo "$TB_CASSANDRA_SCHEMA_URL container completed!" | ||
30 | - reachable=1 | ||
31 | - fi | ||
32 | -done | 21 | +if [ "$DATABASE_TYPE" == "cassandra" ]; then |
22 | + until nmap cassandra -p 9042 | grep "9042/tcp open" | ||
23 | + do | ||
24 | + echo "Wait for cassandra db to start..." | ||
25 | + sleep 10 | ||
26 | + done | ||
27 | +fi | ||
28 | + | ||
29 | +if [ "$DATABASE_TYPE" == "sql" ]; then | ||
30 | + if [ "$SPRING_DRIVER_CLASS_NAME" == "org.postgresql.Driver" ]; then | ||
31 | + until nmap postgres -p 5432 | grep "5432/tcp open" | ||
32 | + do | ||
33 | + echo "Waiting for postgres db to start..." | ||
34 | + sleep 10 | ||
35 | + done | ||
36 | + fi | ||
37 | +fi | ||
38 | + | ||
39 | +if [ "$ADD_SCHEMA_AND_SYSTEM_DATA" == "true" ]; then | ||
40 | + echo "Creating 'Thingsboard' schema and system data..." | ||
41 | + if [ "$ADD_DEMO_DATA" == "true" ]; then | ||
42 | + echo "Adding demo data..." | ||
43 | + /usr/share/thingsboard/bin/install/install.sh --loadDemo | ||
44 | + elif [ "$ADD_DEMO_DATA" == "false" ]; then | ||
45 | + /usr/share/thingsboard/bin/install/install.sh | ||
46 | + fi | ||
47 | +fi | ||
48 | + | ||
33 | 49 | ||
34 | # Copying env variables into conf files | 50 | # Copying env variables into conf files |
35 | printenv | awk -F "=" '{print "export " $1 "='\''" $2 "'\''"}' >> /usr/share/thingsboard/conf/thingsboard.conf | 51 | printenv | awk -F "=" '{print "export " $1 "='\''" $2 "'\''"}' >> /usr/share/thingsboard/conf/thingsboard.conf |