100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Work on deployment profiles
Christian Bauer1646eb66f140
diff --git a/README.md b/README.mdindex 614e73820..b829c5eda 100644--- a/README.md+++ b/README.md@@ -12,15 +12,37 @@ If you want to try OpenRemote v2, [read the OpenRemote v2 documentation](https:/We work with Java, Groovy, JavaScript, Gradle, Docker, and a wide range of APIs and protocol implementations. Clone or checkout this project and send us pull requests.-First, checkout this project.+First, checkout this project or at a minimum, get the Docker Compose [profiles](profile/).-A demo can be started with downloaded dependencies and images (install [Docker Community Edition](https://www.docker.com/)):+You'll need [Docker Community Edition](https://www.docker.com/) for Windows, macOS, or Linux.++Also see our [developer guide](https://github.com/openremote/openremote/wiki) for more details.++### Starting a demo stack++A demo stack can be started with downloaded dependencies and images (you only have to get the [profiles](profile/)):```-./gradlew clean installDistdocker-compose -p openremote -f profile/demo.yml up --no-build```+Access the manager UI and API on https://localhost/ with username `admin` and password `secret`. Accept the 'insecure' self-signed SSL certificate.++Stop the stack and remove all unused data volumes (on your host!) with:++```+docker-compose -p openremote -f profile/demo.yml down+docker volume prune+```++More configuration options of the images are documented [in the deploy.yml profile](https://github.com/openremote/openremote/blob/master/profile/deploy.yml).++### Preserving demo data++To keep your data, don't delete the Docker volumes `openremote_manger-data` and `openremote_postgresql-data` between restarts. You must also change `SETUP_WIPE_CLEAN_INSTALL` to `false` in `demo.yml`!++### Building images from source+If you want to build the images instead of downloading them, execute:```@@ -28,22 +50,28 @@ If you want to build the images instead of downloading them, execute:docker-compose -p openremote -f profile/demo.yml up --build```-Access the manager UI and API on https://localhost/ with username `admin` and password `secret` (accept the 'insecure' self-signed SSL certificate).+### Using `dev` profiles-To keep your data, backup the `deployment` directory and start the stack with `SETUP_INIT_CLEAN_DATABASE=false docker-compose ... up`. You can specify an alternative deployment directory with `DEPLOYMENT_DIRECTORY=/my/data docker-compose ... up`.+Also consider using the `dev` profiles if you want to change code, they will run required services in the background for various development/build tasks. The whole stack in development mode can be started with:-More configuration options of the images are documented [in the deploy.yml profile](https://github.com/openremote/openremote/blob/master/profile/deploy.yml).+```+./gradlew clean installDist+docker-compose -p openremote -f profile/dev.yml up --build+```++### Committing changes-Perform a clean build, delete all data volumes (!), and run all tests (before committing):+Perform a clean build, delete all data volumes (!), and run all tests before committing:```docker volume prune-docker-compose -p openremote -f profile/dev.yml up -d+docker-compose -p openremote -f profile/dev-testing.yml up -d./gradlew clean build installDistdocker build -t openremote/proxy:latest haproxydocker build -t openremote/postgresql:latest postgresqldocker build -t openremote/keycloak:latest keycloak-docker build -t openremote/manager:latest manager/build/install+docker build -t openremote/manager:latest manager/build/install/manager+docker-compose -p openremote -f profile/dev-testing.yml down```Push images to [Docker Hub](https://hub.docker.com/u/openremote):diff --git a/agent/build.gradle b/agent/build.gradleindex 3e9d4f607..92104fd16 100644--- a/agent/build.gradle+++ b/agent/build.gradle@@ -27,4 +27,8 @@ dependencies {compile "org.fourthline.cling:cling-core:$clingVersion"compile "net.sf.saxon:Saxon-HE:$saxonHEVersion"+}++jar {+ archivesBaseName = "openremote-${project.name}"}\ No newline at end of filediff --git a/container/build.gradle b/container/build.gradleindex 22af78e1e..5da3db658 100644--- a/container/build.gradle+++ b/container/build.gradle@@ -55,3 +55,7 @@ dependencies {exclude group: "javax.servlet"}}++jar {+ archivesBaseName = "openremote-${project.name}"+}\ No newline at end of filediff --git a/container/src/main/java/org/openremote/container/util/LogUtil.java b/container/src/main/java/org/openremote/container/util/LogUtil.javaindex fd9757be5..8f164dbc2 100644--- a/container/src/main/java/org/openremote/container/util/LogUtil.java+++ b/container/src/main/java/org/openremote/container/util/LogUtil.java@@ -33,8 +33,9 @@ public class LogUtil {/*** If system property <code>java.util.logging.config.file</code> has not been set, try to load the* logging configuration specified in environment variable <code>LOGGING_CONFIG_FILE</code> as a file.- * If this also wasn't set, load the given default logging configuration from the classpath.- *+ * If this wasn't set, try to find the file <code>/deployment/logging.properties</code>.+ * If this also wasn't found, load the given default logging configuration from the classpath.+ * <p>* This method should be called in a <code>static { ... }</code> block in the "first" class of your* application (typically where your <code>main()</code> method is located).*/@@ -49,16 +50,25 @@ public class LogUtil {} catch (Exception ex) {throw new ExceptionInInitializerError(ex);}- // Or load a default configuration from the classpath} else {- try (InputStream is = Container.class.getClassLoader().getResourceAsStream(defaultLoggingProperties)) {- if (is != null) {+ // Try to find /deployment/logging.properties+ if (Files.isReadable(Paths.get("/deployment/logging.properties"))) {+ try (InputStream is = Files.newInputStream(Paths.get("/deployment/logging.properties"))) {LogManager.getLogManager().readConfiguration(is);+ } catch (Exception ex) {+ throw new ExceptionInInitializerError(ex);+ }+ } else {+ // Or load a default configuration from the classpath+ try (InputStream is = Container.class.getClassLoader().getResourceAsStream(defaultLoggingProperties)) {+ if (is != null) {+ LogManager.getLogManager().readConfiguration(is);+ }+ } catch (Exception ex) {+ throw new ExceptionInInitializerError(ex);}- } catch (Exception ex) {- throw new ExceptionInInitializerError(ex);}}}}-}+}\ No newline at end of filediff --git a/manager/client/src/main/webapp/css/theme.html b/manager/client/src/main/webapp/css/theme.htmlindex f2013d924..fd9ee175b 100644--- a/manager/client/src/main/webapp/css/theme.html+++ b/manager/client/src/main/webapp/css/theme.html@@ -2,23 +2,6 @@<template><style>- :root {- --theme-white: #ffffff; /* rgb(255, 255, 255); */- --theme-black: #000000; /* rgb(0, 0, 0); */- --theme-darkgreen: #006224; /* rgb(0, 98, 36); */- --theme-mediumgreen: #49a942; /* rgb(73, 169, 66); */- --theme-lightgreen: #c1d72f; /* rgb(193, 215, 47); */- --theme-darkgrey: #374c4f; /* rgb(55, 76, 79) */- --theme-mediumgrey: #919194; /* rgb(145, 145, 148); */- --theme-lightgrey: #cccccc; /* rgb(204, 204, 204); */- --theme-lightergrey: #e5e5e5; /* rgb(229, 229, 229); */- --theme-brightgrey: #f5f5f5; /* rgb(245, 245, 245); */- --theme-red: #e64a19; /* rgb(230, 74, 25); */- --theme-yellow: #fbc02d; /* rgb(251, 192, 45); */- --theme-blue: #1976d2; /* rgb(25, 118, 210); */- --theme-purple: #660092; /* rgb(102, 0, 146) */- }-::-webkit-scrollbar-track {background-color: var(--theme-black);}diff --git a/manager/client/src/main/webapp/index.html b/manager/client/src/main/webapp/index.htmlindex 619767e5c..32f28bd1c 100644--- a/manager/client/src/main/webapp/index.html+++ b/manager/client/src/main/webapp/index.html@@ -17,8 +17,9 @@<link rel="import" href="/static/css/style.html"><link rel="import" href="/static/css/theme.html">+ <link rel="import" href="/ui/colors.html"><custom-style>- <style include="global-style global-theme"></style>+ <style include="global-style global-theme colors"></style></custom-style><script>diff --git a/manager/server/build.gradle b/manager/server/build.gradleindex fc3d445ac..e2137e421 100644--- a/manager/server/build.gradle+++ b/manager/server/build.gradle@@ -18,3 +18,7 @@ dependencies {compile "org.xerial:sqlite-jdbc:$sqliteVersion"}++jar {+ archivesBaseName = "openremote-manager-${project.name}"+}\ No newline at end of filediff --git a/manager/server/src/main/java/org/openremote/manager/server/map/MapService.java b/manager/server/src/main/java/org/openremote/manager/server/map/MapService.javaindex 1865f4602..88e66f93e 100644--- a/manager/server/src/main/java/org/openremote/manager/server/map/MapService.java+++ b/manager/server/src/main/java/org/openremote/manager/server/map/MapService.java@@ -171,7 +171,7 @@ public class MapService implements ContainerService {vectorTiles.put("minzoom", Integer.valueOf(resultMap.get("minzoom")));vectorTiles.put("attribution", resultMap.get("attribution"));} catch (Exception ex) {- throw new RuntimeException(ex);+ throw new RuntimeException("Error opening database: " + this, ex);} finally {closeQuietly(query, result);}@@ -225,7 +225,8 @@ public class MapService implements ContainerService {@Overridepublic String toString() {return getClass().getSimpleName() + "{" +- "mapSettingsPath=" + mapSettingsPath ++ "mapTilesPath=" + mapTilesPath ++ ", mapSettingsPath=" + mapSettingsPath +'}';}}\ No newline at end of filediff --git a/manager/shared/build.gradle b/manager/shared/build.gradleindex 019a0f143..9013b935a 100644--- a/manager/shared/build.gradle+++ b/manager/shared/build.gradle@@ -15,4 +15,5 @@ dependencies {jar {from sourceSets.main.allJava+ archivesBaseName = "openremote-manager-${project.name}"}\ No newline at end of filediff --git a/model/build.gradle b/model/build.gradleindex 87b341308..859554a38 100644--- a/model/build.gradle+++ b/model/build.gradle@@ -18,4 +18,5 @@ dependencies {jar {from sourceSets.main.allJava+ archivesBaseName = "openremote-${project.name}"}\ No newline at end of filediff --git a/profile/README.md b/profile/README.mdnew file mode 100644index 000000000..596d24af6--- /dev/null+++ b/profile/README.md@@ -0,0 +1,14 @@+# OpenRemote v3 Docker Stacks++The profiles extend each other, your project should also extend them:++* [deploy.yml](/deploy.yml) - The root profile with default settings, should be extended only++ * [demo.yml](/demo.yml) - A transient demo stack for x86 hosts, copy and modify for permanent installation++ * [demo-rpi.yml](/demo-rpi.yml) - Settings for deployment on Raspberry Pi3 aarch32 host++ * [dev.yml](/dev.yml) - A transient development stack with all services, uses local bind mounts++ * [dev-testing.yml](/dev-testing.yml) - A transient development minimal services stack used to run build tests and work in IDE+diff --git a/profile/deploy-rpi.yml b/profile/demo-rpi.ymlsimilarity index 94%rename from profile/deploy-rpi.ymlrename to profile/demo-rpi.ymlindex 7ef15c5e7..24d25a5ca 100644--- a/profile/deploy-rpi.yml+++ b/profile/demo-rpi.yml@@ -1,6 +1,9 @@+## Demo setup of OpenRemote v3 on Rasperry Pi 3#-version: '2.1'+# TODO: Needs updating for fast JDK9 aarch32 JVM, or JDK8 aarch64 JVM+#+version: '2.2'services:diff --git a/profile/demo.yml b/profile/demo.ymlindex d66cb965b..075462b87 100644--- a/profile/demo.yml+++ b/profile/demo.yml@@ -73,7 +73,7 @@ services:depends_on:keycloak:condition: service_healthy- volumes:+ # volumes:# Use local deployment data in host-mapped directory for easy development. The# ../deployment directory is the one which will be baked into the managers image.# - ${DEPLOYMENT_DIRECTORY:-../deployment}/manager:/deployment@@ -83,13 +83,12 @@ services:# giving you a default configuration to modify. Access the volume with:## docker run --rm -it -v openremote_manager-data:/deployment centos:7 /bin/bash+ # > ls -la /deployment#- - manager-data:/deployment-+ # To use a volume, enable this:+ #+ # - manager-data:/deploymentenvironment:- # Override built-in logging.properties with a file of your choice.- LOGGING_CONFIG_FILE: '/deployment/logging.properties'-# This switch can wipe all your Manager and Keycloak data, this is the factory reset!SETUP_WIPE_CLEAN_INSTALL: 'true'# When you are ready to permanently install your project, replace it with the next lines...diff --git a/profile/deploy.yml b/profile/deploy.ymlindex 01400bccf..1d6803377 100644--- a/profile/deploy.yml+++ b/profile/deploy.yml@@ -1,8 +1,5 @@# OpenRemote v3#-# By default running this profile installs the stack on https://localhost using a-# self-signed SSL certificate, with username 'admin' and password 'secret'.-## Install Docker Community edition (https://docker.com/) on Windows, macOS, or Linux.## Start the stack with:@@ -148,6 +145,9 @@ services:# have the name of a realm to which the console app belongs.# CONSOLES_DOCROOT: '/deployment/consoles'+ # Optional: Custom location of the Manager UI customisations.+ # UI_DOCROOT: '/deployment/ui'+# Optional: Provide a path to the map tiles database file (see https://openmaptiles.com/).# MAP_TILES_PATH: '/deployment/map/mapdata.mbtiles'@@ -155,6 +155,9 @@ services:# manager's map, as well as other style details and colours.# MAP_SETTINGS_PATH: '/deployment/map/mapsettings.json'+ # Override logging.properties with a file of your choice.+ # LOGGING_CONFIG_FILE: '/deployment/logging.properties'+# The number of threads and therefore rules engines that can be instantiated (default unlimited).# RULES_THREADS_MAX: 32diff --git a/profile/dev-console.yml b/profile/dev-console.ymldeleted file mode 100644index 09c0b44da..000000000--- a/profile/dev-console.yml+++ /dev/null@@ -1,51 +0,0 @@-# Profile for doing development on the consoles and keycloak theme only.-# Starts haproxy, letsencrypt, keycloak with theme volumed mapped and postgres and exposes haproxy to localhost.-version: '2.2'--volumes:- proxy-data:- #manager-data:- postgresql-data:--services:-- proxy:- extends:- file: deploy.yml- service: proxy- depends_on:- manager:- condition: service_healthy- volumes:- - proxy-data:/deployment-- manager:- extends:- file: deploy.yml- service: manager- environment:- DEV_MODE: 'true'- depends_on:- keycloak:- condition: service_healthy-- keycloak:- extends:- file: deploy.yml- service: keycloak- build:- context: ../keycloak- dockerfile: dev.Dockerfile- image: openremote/keycloak_dev:latest- volumes:- - ../keycloak/theme:/opt/jboss/keycloak/themes/openremote- depends_on:- postgresql:- condition: service_healthy-- postgresql:- extends:- file: deploy.yml- service: postgresql- volumes:- - postgresql-data:/deploymentdiff --git a/profile/dev-testing.yml b/profile/dev-testing.ymlnew file mode 100644index 000000000..41068bb3f--- /dev/null+++ b/profile/dev-testing.yml@@ -0,0 +1,36 @@+#+# Profile for doing IDE development work and running build tests.+#+# Run this in the background for full ./gradlew clean build+#+version: '2.2'++volumes:+ postgresql-data:++services:++ keycloak:+ extends:+ file: deploy.yml+ service: keycloak+ ports:+ - "8081:8080"+ build:+ context: ../keycloak+ dockerfile: dev.Dockerfile+ image: openremote/keycloak_dev:latest+ volumes:+ - ../keycloak/theme:/opt/jboss/keycloak/themes/openremote+ depends_on:+ postgresql:+ condition: service_healthy++ postgresql:+ extends:+ file: deploy.yml+ service: postgresql+ ports:+ - "5432:5432"+ volumes:+ - postgresql-data:/data\ No newline at end of filediff --git a/profile/dev.yml b/profile/dev.ymlindex 83665edb2..23f149655 100644--- a/profile/dev.yml+++ b/profile/dev.yml@@ -1,12 +1,50 @@-# Profile for doing development on all services.-# Starts keycloak with theme volumed mapped and postgres and exposes them to localhost.+#+# Profile for doing development work on full stack.+#+# Your changes will be visible live on browser reload or after restart:+#+# - Edit files in deployment/manager/+# - Edit files in keycloak/theme/+# - Mount the proxy-data volume in a new container and edit proxy configuration files+# - Change the proxy configuration to a directory mount and edit configuration files+#version: '2.2'volumes:+ proxy-data:postgresql-data:services:+ proxy:+ extends:+ file: deploy.yml+ service: proxy+ depends_on:+ manager:+ condition: service_healthy+ volumes:+ # Store data either in host-mapped directory or a named Docker volume+ # - ${DEPLOYMENT_DIRECTORY:-../deployment}/proxy:/deployment+ - proxy-data:/deployment++ manager:+ extends:+ file: deploy.yml+ service: manager+ environment:+ DEV_MODE: 'true'+ depends_on:+ keycloak:+ condition: service_healthy+ volumes:+ # Use local deployment data in host-mapped directory for easy development. The+ # ../deployment directory is the one which will be baked into the managers image.+ - ${DEPLOYMENT_DIRECTORY:-../deployment}/manager:/deployment+ environment:+ # This switch can wipe all your Manager and Keycloak data, this is the factory reset!+ SETUP_WIPE_CLEAN_INSTALL: 'true'+keycloak:extends:file: deploy.yml