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
Preparation for a multinode swarm, tested on AWS
Michal Rutka2df5a6182846
diff --git a/docker-compose-swarm.yml b/docker-compose-swarm.ymlindex 8df4deb43..7c78f99c0 100644--- a/docker-compose-swarm.yml+++ b/docker-compose-swarm.yml@@ -40,39 +40,17 @@ volumes:services:- # This service will only populate an empty volume on startup and then exit.- # If the volume already contains data, it exits immediately.-# deployment:-# image: openremote/deployment:${DATE_TAG:-latest}-# volumes:-# - deployment-data:/deployment-- # This configuration does not store SSL certificate data and allow changes to the- # proxy configuration, it is only configured for deployment on localhost. You can- # map a Docker volume or host directory to access/store proxy configuration files- # and SSL certificates.proxy:- # Image will be pulled when using the `docker-compose pull` command or `docker-compose up --no-build`image: openremote/proxy:${DATE_TAG:-latest}networks:- public- privateenvironment:-- # It is important that all services have the same timezone and are time synchronized.- # Bearer tokens are only valid for minutes, and authentication fails if Keycloak drifts.TZ: Europe/Amsterdam-- # The public host name of this OpenRemote installation. Set this to request/manage an SSL- # certificate with the free https://letsencrypt.org/ provider. The default 'localhost' will- # rely on a baked-in self-signed certificate. If you change this, adjust manager#IDENTITY_NETWORK_HOST.DOMAINNAME: ${DOMAINNAME:-localhost}-- # Provide your own email address for your SSL certificates with Let's Encrypt. This should- # be set when DOMAINNAME is not 'localhost'.- LE_EMAIL: ${LE_EMAIL:-}+ LE_EMAIL: ${LE_EMAIL:[email protected]}# Enable --staging will manage fake certificates, so avoid hitting the rate limits of Let's Encrypt# when testing (this is important, you are limited to 5 duplicate certificates per week!)diff --git a/keycloak/Dockerfile b/keycloak/Dockerfileindex ef59c5a34..24184e1b7 100644--- a/keycloak/Dockerfile+++ b/keycloak/Dockerfile@@ -1,3 +1,4 @@+FROM openremote/deployment:latest as deploymentFROM jboss/keycloak:7.0.1MAINTAINER [email protected]@@ -15,5 +16,7 @@ USER 1000EXPOSE 8080+COPY --from=deployment /deployment/keycloak/themes/ /opt/jboss/keycloak/themes/+ENTRYPOINT ["/opt/jboss/docker-entrypoint.sh"]CMD ["-b", "0.0.0.0"]\ No newline at end of filediff --git a/keycloak/docker-entrypoint.sh b/keycloak/docker-entrypoint.shindex b94684f69..de27c71f0 100644--- a/keycloak/docker-entrypoint.sh+++ b/keycloak/docker-entrypoint.sh@@ -1,16 +1,4 @@#!/bin/bash-# Symlink each theme from deployment this preserves the default keycloak theme, reasons for this mechanism:-# Cannot volume map a subdir of a named volume-# Want all customisation to be in the /deployment dir and deployment-data volume-if [ -d "/deployment/keycloak/themes" ]; then- for dir in /deployment/keycloak/themes/*; do- if [ -d ${dir} ]; then- echo "${dir##*/}"- ln -s ${dir} /opt/jboss/keycloak/themes/${dir##*/}- fi- done-fi-exec /opt/jboss/tools/docker-entrypoint.sh $@exit $?\ No newline at end of filediff --git a/manager/swarm.Dockerfile b/manager/swarm.Dockerfileindex f699ad90d..2b049cccb 100644--- a/manager/swarm.Dockerfile+++ b/manager/swarm.Dockerfile@@ -1,64 +1,5 @@-FROM debian:stretch-MAINTAINER [email protected]--# Install utilities-RUN apt-get update && apt-get install -y --no-install-recommends \- apt-transport-https \- gnupg2 \- software-properties-common \- procps \- ca-certificates \- curl \- wget \- && rm -rf /var/lib/apt/lists/*--# Default to UTF-8 file.encoding-ENV LANG C.UTF-8--# add a simple script that can auto-detect the appropriate JAVA_HOME value-# based on whether the JDK or only the JRE is installed-RUN { \- echo '#!/bin/sh'; \- echo 'set -e'; \- echo; \- echo 'dirname "$(dirname "$(readlink -f "$(which javac || which java)")")"'; \- } > /usr/local/bin/docker-java-home \- && chmod +x /usr/local/bin/docker-java-home--# do some fancy footwork to create a JAVA_HOME that's cross-architecture-safe-RUN ln -svT "/usr/lib/jvm/java-8-openjdk-$(dpkg --print-architecture)" /docker-java-home-ENV JAVA_HOME /docker-java-home--RUN set -ex; \- \-# deal with slim variants not having man page directories (which causes "update-alternatives" to fail)- if [ ! -d /usr/share/man/man1 ]; then \- mkdir -p /usr/share/man/man1; \- fi; \- \- apt-get update; \- apt-get install -y \- openjdk-8-jdk \- ca-certificates-java\- ; \- rm -rf /var/lib/apt/lists/*; \- \-# verify that "docker-java-home" returns what we expect- [ "$(readlink -f "$JAVA_HOME")" = "$(docker-java-home)" ]; \- \-# update-alternatives so that future installs of other OpenJDK versions don't change /usr/bin/java- update-alternatives --get-selections | awk -v home="$(readlink -f "$JAVA_HOME")" 'index($3, home) == 1 { $2 = "manual"; print | "update-alternatives --set-selections" }'; \-# ... and verify that it actually worked for one of the alternatives we care about- update-alternatives --query java | grep -q 'Status: manual'--# Run postinst because it might not happen on install-RUN /var/lib/dpkg/info/ca-certificates-java.postinst configure--# Add git commit label must be specified at build time using --build-arg GIT_COMMIT=dadadadadad-ARG GIT_COMMIT=unknown-LABEL git-commit=$GIT_COMMIT--ADD lib /opt/app/lib+FROM openremote/manager:latest AS manager+FROM openremote/deployment:latest AS deployment############ EDITS ABOVE THIS LINE SHOULD BE DONE IN ALL DOCKERFILES! ################FROM openjdk:8-jre@@ -78,6 +19,7 @@ WORKDIR /opt/appRUN mkdir -p /deployment/extensions-COPY --from=0 /opt/app/lib /opt/app/lib+COPY --from=manager /opt/app/lib /opt/app/lib+COPY --from=deployment /deployment/ /deployment/ENTRYPOINT java $JAVA_OPTS -cp /opt/app/lib/*:/deployment/manager/extensions/* org.openremote.manager.Main