From f4fe6663b928cd1a941504b1bc15bb3147369ccc Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Thu, 25 Oct 2018 12:34:02 +0300 Subject: [PATCH] MSA docker: Configurable HTTP to HTTPS redirect. Update docker instructions. --- docker/.env | 2 +- docker/README.md | 55 ++++++++++++++++++++++++++++--- docker/docker-compose.yml | 1 + docker/docker-upgrade-tb.sh | 2 ++ docker/haproxy/config/haproxy.cfg | 2 +- msa/tb/README.md | 7 ++-- 6 files changed, 60 insertions(+), 9 deletions(-) diff --git a/docker/.env b/docker/.env index 17f8af8c4e..eb859b17c6 100644 --- a/docker/.env +++ b/docker/.env @@ -13,6 +13,6 @@ TB_VERSION=latest # Database used by ThingsBoard, can be either local (local HSQLDB), postgres (PostgreSQL), cassandra (Cassandra). # In case of postgres or cassandra corresponding docker service will be deployed (see docker-compose.postgres.yml, docker-compose.cassandra.yml for details). -DATABASE=cassandra +DATABASE=local KAFKA_TOPICS="js.eval.requests:100:1:delete --config=retention.ms=60000 --config=segment.bytes=26214400 --config=retention.bytes=104857600,tb.transport.api.requests:30:1:delete --config=retention.ms=60000 --config=segment.bytes=26214400 --config=retention.bytes=104857600,tb.rule-engine:30:1" diff --git a/docker/README.md b/docker/README.md index e8fd55e532..769a9f9a20 100644 --- a/docker/README.md +++ b/docker/README.md @@ -2,24 +2,63 @@ This folder containing scripts and Docker Compose configurations to run ThingsBoard in Microservices mode. +## Prerequisites + +ThingsBoard Microservices are running in dockerized environment. +Before starting please make sure [Docker CE](https://docs.docker.com/install/) and [Docker Compose](https://docs.docker.com/compose/install/) are installed in your system. + ## Installation -Execute the following command to run DataBase installation: +Before performing initial installation you can configure the type of database to be used with ThinsBoard. +In order to set database type change the value of `DATABASE` variable in `.env` file to one of the following: + +- `local` - use local embedded HSQLDB database; +- `postgres` - use PostgreSQL database; +- `cassandra` - use Cassandra database; + +**NOTE**: In case of `postgres` or `cassandra` corresponding docker service will be deployed (see `docker-compose.postgres.yml`, `docker-compose.cassandra.yml` for details). + +Execute the following command to run installation: ` $ ./docker-install-tb.sh --loadDemo ` -- `--loadDemo` - optional argument. Whether to load additional demo data. +Where: + +- `--loadDemo` - optional argument. Whether to load additional demo data. ## Running -Execute the following command to run services: +Execute the following command to start services: ` $ ./docker-start-services.sh ` +After a while when all services will be successfully started you can open `http://{yor-host-ip}` in you browser (for ex. `http://localhost`). +You should see ThingsBoard login page. + +Use the following default credentials: + +- **Systen Administrator**: sysadmin@thingsboard.org / sysadmin + +If you installed DataBase with demo data (using `--loadDemo` flag) you can also use the following credentials: + +- **Tenant Administrator**: tenant@thingsboard.org / tenant +- **Customer User**: customer@thingsboard.org / customer + +In case of any issues you can examine service logs for errors. +For example to see ThingsBoard node logs execute the following command: + +` +$ docker-compose logs -f tb +` + +Or use `docker-compose ps` to see the state of all the containers. +Use `docker-compose logs --f` to inspect the logs of all running services. +See [docker-compose logs](https://docs.docker.com/compose/reference/logs/) command reference for details. + Execute the following command to stop services: ` @@ -32,12 +71,16 @@ Execute the following command to stop and completely remove deployed docker cont $ ./docker-remove-services.sh ` -Execute the following command to update particular services (pull newer docker image and rebuild container): +Execute the following command to update particular or all services (pull newer docker image and rebuild container): ` $ ./docker-update-service.sh [SERVICE...] ` +Where: + +- `[SERVICE...]` - list of services to update (defined in docker-compose configurations). If not specified all services will be updated. + ## Upgrading In case when database upgrade is needed, execute the following commands: @@ -48,4 +91,6 @@ $ ./docker-upgrade-tb.sh --fromVersion=[FROM_VERSION] $ ./docker-start-services.sh ``` -- `FROM_VERSION` - from which version upgrade should be started. +Where: + +- `FROM_VERSION` - from which version upgrade should be started. See [Upgrade Instructions](https://thingsboard.io/docs/user-guide/install/upgrade-instructions) for valid `fromVersion` values. diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index a319606c03..fd0c80c28b 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -171,6 +171,7 @@ services: HTTP_PORT: 80 HTTPS_PORT: 443 MQTT_PORT: 1883 + FORCE_HTTPS_REDIRECT: "false" links: - tb-web-ui1 - tb-web-ui2 diff --git a/docker/docker-upgrade-tb.sh b/docker/docker-upgrade-tb.sh index 500b09a81e..c594b9d3f9 100755 --- a/docker/docker-upgrade-tb.sh +++ b/docker/docker-upgrade-tb.sh @@ -46,6 +46,8 @@ ADDITIONAL_COMPOSE_ARGS=$(additionalComposeArgs) || exit $? ADDITIONAL_STARTUP_SERVICES=$(additionalStartupServices) || exit $? +docker-compose -f docker-compose.yml $ADDITIONAL_COMPOSE_ARGS pull tb + if [ ! -z "${ADDITIONAL_STARTUP_SERVICES// }" ]; then docker-compose -f docker-compose.yml $ADDITIONAL_COMPOSE_ARGS up -d $ADDITIONAL_STARTUP_SERVICES fi diff --git a/docker/haproxy/config/haproxy.cfg b/docker/haproxy/config/haproxy.cfg index cb70552a73..bb1062f2a2 100644 --- a/docker/haproxy/config/haproxy.cfg +++ b/docker/haproxy/config/haproxy.cfg @@ -51,7 +51,7 @@ frontend http-in acl transport_http_acl path_beg /api/v1/ acl letsencrypt_http_acl path_beg /.well-known/acme-challenge/ - redirect scheme https if !letsencrypt_http_acl !transport_http_acl + redirect scheme https if !letsencrypt_http_acl !transport_http_acl { env(FORCE_HTTPS_REDIRECT) -m str true } use_backend letsencrypt_http if letsencrypt_http_acl use_backend tb-http-backend if transport_http_acl diff --git a/msa/tb/README.md b/msa/tb/README.md index d165fa7c3b..4caeeadcb6 100644 --- a/msa/tb/README.md +++ b/msa/tb/README.md @@ -8,6 +8,7 @@ This project provides the build for the ThingsBoard single docker images. ## Running +In this example `thingsboard/tb` image will be used. You can choose any other images with different databases (see above). Execute the following command to run this docker directly: ` @@ -23,9 +24,9 @@ Where: - `-p 5683:5683` - connect local port 5683 to exposed internal COAP port 5683 - `-v ~/.mytb-data:/data` - mounts the host's dir `~/.mytb-data` to ThingsBoard DataBase data directory - `--name mytb` - friendly local name of this machine -- `thingsboard/tb` - docker image +- `thingsboard/tb` - docker image, can be also `thingsboard/tb-postgres` or `thingsboard/tb-cassandra` -After executing this command you can open `http://{yor-host-ip}:9090` in you browser. You should see ThingsBoard login page. +After executing this command you can open `http://{yor-host-ip}:9090` in you browser (for ex. `http://localhost:9090`). You should see ThingsBoard login page. Use the following default credentials: - **Systen Administrator**: sysadmin@thingsboard.org / sysadmin @@ -65,4 +66,6 @@ $ docker run -it -v ~/.mytb-data:/data --rm thingsboard/tb upgrade-tb.sh $ docker start mytb ``` +**NOTE**: if you use different database change image name in all commands from `thingsboard/tb` to `thingsboard/tb-postgres` or `thingsboard/tb-cassandra` correspondingly. + **NOTE**: replace host's directory `~/.mytb-data` with directory used during container creation.