-
Notifications
You must be signed in to change notification settings - Fork 70
Add TLS-enabled PostgreSQL and ThingsBoard integration, update README #1367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sigurd-rbj
wants to merge
6
commits into
INTO-CPS-Association:feature/distributed-demo
Choose a base branch
from
sigurd-rbj:feature/services-tls-thingsboard
base: feature/distributed-demo
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
685d8f2
Add TLS-enabled PostgreSQL and ThingsBoard integration, update README…
sigurd-rbj c059009
Add ThingsBoard tenant and user setup instructions
sigurd-rbj def62af
Add automated ThingsBoard setup, update services.env.template, and ex…
sigurd-rbj 7f651b5
Add SQL init script, update README, compose, env template, user script
sigurd-rbj 026f84a
Update ThingsBoard script
sigurd-rbj 694b96d
Update README installation steps and commands
sigurd-rbj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -92,6 +92,64 @@ services: | |
| networks: | ||
| - platform-services | ||
|
|
||
| postgres: | ||
| image: 'postgres:16.11' | ||
| container_name: postgres | ||
| restart: always | ||
| ports: | ||
| - '${POSTGRES_PORT}:5432' | ||
| volumes: | ||
| - './data/postgres:/var/lib/postgresql/data' | ||
| - './certs/${HOSTNAME}:/etc/ssl' | ||
| #- './config/init-thingsboard-user.sql:/docker-entrypoint-initdb.d/init-thingsboard-user.sql:ro' | ||
| environment: | ||
| POSTGRES_DB: '${POSTGRES_DB}' | ||
| POSTGRES_USER: '${POSTGRES_USER}' | ||
| POSTGRES_PASSWORD: '${POSTGRES_PASSWORD}' | ||
| command: | ||
| - postgres | ||
| - -c | ||
| - ssl=on | ||
| - -c | ||
| - ssl_cert_file=/etc/ssl/postgres.crt | ||
| - -c | ||
| - ssl_key_file=/etc/ssl/postgres.key | ||
| networks: | ||
| - platform-services | ||
|
|
||
| thingsboard-ce: | ||
| image: 'thingsboard/tb-node:4.2.1' | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please check the advantage of this image versus tb-postgres. If you can make both work, we can have a live comparison of both the setups. |
||
| container_name: thingsboard | ||
| restart: always | ||
| ports: | ||
| - '${THINGSBOARD_PORT}:8080' | ||
| - '${THINGSBOARD_EDGE_RPC_PORT}:7070' | ||
| - '${THINGSBOARD_MQTT_PORT}:1883' | ||
| - '${THINGSBOARD_MQTT_SSL_PORT}:8883' | ||
| - '${THINGSBOARD_COAP_LwM2M_PORTS}:5683-5688/udp' | ||
| volumes: | ||
| - './log/thingsboard:/var/log/thingsboard' | ||
| - './data/thingsboard:/data' | ||
| - './certs/${HOSTNAME}:/certs' | ||
| environment: | ||
| TB_SERVICE_ID: tb-ce-node | ||
| SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/${POSTGRES_DB}?sslmode=require | ||
| SPRING_DATASOURCE_USERNAME: ${POSTGRES_USER} | ||
| SPRING_DATASOURCE_PASSWORD: ${POSTGRES_PASSWORD} | ||
| SSL_ENABLED: "true" | ||
| SSL_CREDENTIALS_TYPE: "PEM" | ||
| SSL_PEM_CERT: "/certs/fullchain-thingsboard.pem" | ||
| SSL_PEM_KEY: "/certs/privkey-thingsboard.pem" | ||
| logging: | ||
| driver: 'json-file' | ||
| options: | ||
| max-size: '100m' | ||
| max-file: '10' | ||
| depends_on: | ||
| - postgres | ||
| networks: | ||
| - platform-services | ||
|
|
||
| networks: | ||
| platform-services: | ||
| name: dtaas-platform-services | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| -- 1) Create login role if it doesn't exist | ||
| DO | ||
| $$ | ||
| BEGIN | ||
| IF NOT EXISTS (SELECT FROM pg_roles WHERE rolname = 'dtaas_user') THEN | ||
| CREATE ROLE dtaas_user LOGIN PASSWORD 'dtaas_secret'; | ||
| END IF; | ||
| END | ||
| $$; | ||
|
|
||
| -- Ensure the database exists | ||
| DO | ||
| $$ | ||
| BEGIN | ||
| IF NOT EXISTS (SELECT FROM pg_database WHERE datname = 'thingsboard') THEN | ||
| CREATE DATABASE thingsboard OWNER postgres; | ||
| END IF; | ||
| END | ||
| $$; | ||
|
|
||
| -- Allow the user to connect | ||
| GRANT CONNECT ON DATABASE thingsboard TO dtaas_user; | ||
|
|
||
| -- Switch into the database | ||
| \c thingsboard | ||
|
|
||
| -- Make dtaas_user the owner of the schema | ||
| ALTER SCHEMA public OWNER TO dtaas_user; | ||
|
|
||
| -- Grant broad access to schema | ||
| GRANT ALL ON SCHEMA public TO dtaas_user; | ||
|
|
||
| -- Existing objects (tables/sequences created later will inherit defaults) | ||
| GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO dtaas_user; | ||
| GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO dtaas_user; | ||
|
|
||
| -- Default privileges for newly created objects | ||
| ALTER DEFAULT PRIVILEGES IN SCHEMA public | ||
| GRANT ALL ON TABLES TO dtaas_user; | ||
|
|
||
| ALTER DEFAULT PRIVILEGES IN SCHEMA public | ||
| GRANT ALL ON SEQUENCES TO dtaas_user; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The data and log directories of thingsboard need specific permissions
Please see this page