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
Updated docker images (based off debian stretch-slim) and using standard 3rd party images where possible (all images except keycloak support multi arch)
Rich Turner819ba379dd60
diff --git a/container/src/main/java/org/openremote/container/persistence/PersistenceService.java b/container/src/main/java/org/openremote/container/persistence/PersistenceService.javaindex 5a3d71425..9dfe3d22c 100644--- a/container/src/main/java/org/openremote/container/persistence/PersistenceService.java+++ b/container/src/main/java/org/openremote/container/persistence/PersistenceService.java@@ -66,7 +66,7 @@ public class PersistenceService implements ContainerService {public static final String DATABASE_CONNECTION_URL = "DATABASE_CONNECTION_URL";public static final String DATABASE_CONNECTION_URL_DEFAULT = "jdbc:postgresql://localhost:5432/openremote";public static final String DATABASE_USERNAME = "DATABASE_USERNAME";- public static final String DATABASE_USERNAME_DEFAULT = "openremote";+ public static final String DATABASE_USERNAME_DEFAULT = "postgres";public static final String DATABASE_PASSWORD = "DATABASE_PASSWORD";public static final String DATABASE_PASSWORD_DEFAULT = "CHANGE_ME_DB_USER_PASSWORD";public static final String DATABASE_MIN_POOL_SIZE = "DATABASE_MIN_POOL_SIZE";diff --git a/deployment/Dockerfile b/deployment/Dockerfileindex 241d182fe..08e162e79 100644--- a/deployment/Dockerfile+++ b/deployment/Dockerfile@@ -1,5 +1,5 @@# Default deployment when delpoyment-data volume is empty-FROM alpine+FROM debian:stretch-slim# Add git commit label must be specified at build time using --build-arg GIT_COMMIT=dadadadadadARG GIT_COMMIT=unknowndiff --git a/manager/Dockerfile b/manager/Dockerfileindex 7e5d82636..30f187b13 100644--- a/manager/Dockerfile+++ b/manager/Dockerfile@@ -1,65 +1,16 @@-FROM debian:stretch-MAINTAINER [email protected]+# TODO: Switch to adoptopenjdk 8u232-b9 once it also supports armhf+FROM debian:stretch-slim-# 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/*+# JRE package expects man dir to exist but doesn't in slim+RUN mkdir -p /usr/share/man/man1-# 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+RUN apt-get update && apt-get install -y curl openjdk-8-jre-headless --no-install-recommends && rm -rf /var/lib/apt/lists/*+ENV JAVA_HOME /etc/alternatives/java# Add git commit label must be specified at build time using --build-arg GIT_COMMIT=dadadadadadARG GIT_COMMIT=unknownLABEL git-commit=$GIT_COMMIT-############ EDITS ABOVE THIS LINE SHOULD BE DONE IN ALL DOCKERFILES! ################-ENV JAVA_OPTS -Xmx1gENV APP_DOCROOT /deployment/manager/app@@ -72,10 +23,12 @@ EXPOSE 8080HEALTHCHECK --interval=3s --timeout=3s --start-period=2s --retries=120 CMD curl --fail --silent http://localhost:8080 || exit 1+RUN mkdir -p /opt/app+WORKDIR /opt/appRUN mkdir -p /deployment/extensionsADD lib /opt/app/lib-ENTRYPOINT java $JAVA_OPTS -cp /opt/app/lib/*:/deployment/manager/extensions/* org.openremote.manager.Main+ENTRYPOINT java $JAVA_OPTS -cp /opt/app/lib/*:/deployment/extensions/* org.openremote.manager.Main\ No newline at end of filediff --git a/manager/rpi3.Dockerfile b/manager/rpi3.Dockerfiledeleted file mode 100644index e9d7945e6..000000000--- a/manager/rpi3.Dockerfile+++ /dev/null@@ -1,42 +0,0 @@-FROM openremote/rpi-raspbian:latest--ENV LANG C.UTF-8--RUN [ "cross-build-start" ]--# OpenJDK with slow interpreter JIT-#RUN apt-get update && apt-get install -y openjdk-8-jdk-headless --no-install-recommends && rm -rf /var/lib/apt/lists/*-#ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-armhf--# Oracle JDK with bad licensing - Make sure you understand the cost before using this in production!-RUN echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee /etc/apt/sources.list.d/webupd8team-java.list && \- echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list && \- apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EEA14886 && \- apt-get update && \- echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-selections && \- echo debconf shared/accepted-oracle-license-v1-1 seen true | debconf-set-selections && \- DEBIAN_FRONTEND=noninteractive apt-get install -y --force-yes oracle-java8-installer oracle-java8-set-default && \- rm -rf /var/cache/oracle-jdk8-installer && \- apt-get clean && \- rm -rf /var/lib/apt/lists/*-ENV JAVA_HOME /usr/lib/jvm/java-8-oracle-ENV JAVA_OPTS -Xmx500m--RUN [ "cross-build-end" ]--ENV APP_DOCROOT /deployment/manager/app-ENV SHARED_DOCROOT /deployment/manager/shared-ENV LOGGING_CONFIG_FILE /deployment/manager/logging.properties-ENV MAP_TILES_PATH /deployment/map/mapdata.mbtiles-ENV MAP_SETTINGS_PATH /deployment/map/mapsettings.json--EXPOSE 8080--HEALTHCHECK --interval=3s --timeout=3s --start-period=2s --retries=30 CMD curl --fail http://localhost:8080 || exit 1--WORKDIR /opt/app--ADD lib /opt/app/lib-ADD client /opt/app--ENTRYPOINT java $JAVA_OPTS -cp /opt/app/lib/*:/deployment/extensions/* org.openremote.manager.Maindiff --git a/postgresql/Dockerfile b/postgresql/Dockerfileindex 0ab67b909..2c5a94b22 100644--- a/postgresql/Dockerfile+++ b/postgresql/Dockerfile@@ -1,53 +1,13 @@-FROM debian:stretch-MAINTAINER [email protected]+# Based on https://github.com/appropriate/docker-postgis/blob/master/9.6-2.5+FROM postgres:9.6-# 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/*+ENV POSTGIS_MAJOR 2.3-ENV PG_VERSION=9.6 \- POSTGIS_VERSION=2.3 \- GOSU_VERSION=1.10--# Use fixed UID/GID-RUN groupadd -r postgres --gid=5432 && useradd -N -r -g postgres --uid=5432 postgres--# Install postgresql/postgisRUN apt-get update \+ && apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \&& apt-get install -y --no-install-recommends \- locales \- postgresql-$PG_VERSION-postgis-$POSTGIS_VERSION \- postgresql-$PG_VERSION-postgis-$POSTGIS_VERSION-scripts \+ postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \+ postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \&& rm -rf /var/lib/apt/lists/*-# Need gosu-RUN curl -L -o /usr/local/bin/gosu https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-amd64 \- && chmod +x /usr/local/bin/gosu \- && gosu nobody true--# Enable UTF8-RUN localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8-ENV LANG en_US.utf8--# Prepare data directory-ENV PGDATA /deployment-RUN mkdir -p "$PGDATA" && chown -R postgres:postgres "$PGDATA"--# Some defaults-ENV PG_BIN=/usr/lib/postgresql/${PG_VERSION}/bin-ENV PATH $PATH:$PG_BIN--EXPOSE 5432--HEALTHCHECK --interval=3s --timeout=3s --start-period=2s --retries=30 CMD gosu postgres pg_isready--COPY entrypoint.sh /-RUN chmod +x /entrypoint.sh-ENTRYPOINT ["/entrypoint.sh"]+HEALTHCHECK --interval=3s --timeout=3s --start-period=2s --retries=30 CMD gosu postgres pg_isready\ No newline at end of filediff --git a/postgresql/entrypoint.sh b/postgresql/entrypoint.shdeleted file mode 100644index 65a387aaa..000000000--- a/postgresql/entrypoint.sh+++ /dev/null@@ -1,55 +0,0 @@-#!/bin/bash-set -e--DB_NAME=${POSTGRES_DB:-}-DB_USER=${POSTGRES_USER:-}-DB_PASS=${POSTGRES_PASSWORD:-}--EXECUTE_SINGLE_COMMAND="gosu postgres ${PG_BIN}/postgres --single -c config_file=${PGDATA}/postgresql.conf -D ${PGDATA}"--# If there is no config file, create config, database, user-if ! [ -f ${PGDATA}/postgresql.conf ]; then- echo "Init database directory (mount a volume on your host to keep data): ${PGDATA}"-- # Create initial database files- gosu postgres ${PG_BIN}/initdb --auth='ident' -E UTF8- chown -R postgres:postgres ${PGDATA}-- # Trust all local connections, allow authenticated IPv4 remote connections- echo "local all all trust" > ${PGDATA}/pg_hba.conf- echo "host all all 127.0.0.1/32 trust" >> ${PGDATA}/pg_hba.conf- echo "host all all 0.0.0.0/0 md5" >> ${PGDATA}/pg_hba.conf- echo "listen_addresses = '0.0.0.0'" >> ${PGDATA}/postgresql.conf-- # Log to stderr- sed -i 's/^logging_collector = on/logging_collector = off/g' ${PGDATA}/postgresql.conf-- # If POSTGRES_USER is set, create a superuser with POSTGRES_PASSWORD- if [ -n "${DB_USER}" ]; then- if [ -z "${DB_PASS}" ]; then- echo "No password specified for user: \"${DB_USER}\""- exit 1- fi- echo "Creating user \"${DB_USER}\"..."- echo "CREATE ROLE ${DB_USER} with superuser login PASSWORD '${DB_PASS}';" | ${EXECUTE_SINGLE_COMMAND} >/dev/null- fi-- # If POSTGRES_DB is set and not 'postgres', create the database and give POSTGRES_USER full access- if [ -n "${DB_NAME}" ] && [ "${DB_NAME}" != 'postgres' ]; then- echo "Creating database \"${DB_NAME}\"..."- echo "CREATE DATABASE ${DB_NAME};" | ${EXECUTE_SINGLE_COMMAND} >/dev/null-- if [ -n "${DB_USER}" ]; then- echo "Granting access to database \"${DB_NAME}\" for user \"${DB_USER}\"..."- echo "GRANT ALL PRIVILEGES ON DATABASE ${DB_NAME} to ${DB_USER};" | ${EXECUTE_SINGLE_COMMAND} >/dev/null- fi- fi-else- echo "Using existing database(s) in: ${PGDATA}"-fi--# Set permissions as on windows permissions will be too relaxed for postgreSQL (even in Docker volume)-chmod -R 0700 ${PGDATA}--echo "Starting database server..."-exec gosu postgres ${PG_BIN}/postgres "$@"diff --git a/postgresql/rpi3.Dockerfile b/postgresql/rpi3.Dockerfiledeleted file mode 100644index 9478c8e3c..000000000--- a/postgresql/rpi3.Dockerfile+++ /dev/null@@ -1,45 +0,0 @@-FROM openremote/rpi-raspbian:latest--ENV PG_VERSION=9.6 \- PG_VERSION_INSTALL=9.6* \- POSTGIS_VERSION=2.3 \- GOSU_VERSION=1.10--RUN [ "cross-build-start" ]--# Use fixed UID/GID-RUN groupadd -r postgres --gid=5432 && useradd -N -r -g postgres --uid=5432 postgres--# Install from repo-RUN apt-get update \- && apt-get install -y --no-install-recommends postgresql-common \- && sed -ri 's/#(create_main_cluster) .*$/\1 = false/' /etc/postgresql-common/createcluster.conf \- && apt-get install -y --no-install-recommends \- postgresql=$PG_VERSION_INSTALL \- postgresql-contrib=$PG_VERSION_INSTALL \- postgresql-$PG_VERSION-postgis-$POSTGIS_VERSION \- postgresql-$PG_VERSION-postgis-$POSTGIS_VERSION-scripts \- && rm -rf /var/lib/apt/lists/*--# Need gosu-RUN curl -L -o /usr/local/bin/gosu https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-armhf \- && chmod +x /usr/local/bin/gosu \- && gosu nobody true--RUN [ "cross-build-end" ]--# Prepare data directory-ENV PGDATA /deployment-RUN mkdir -p "$PGDATA" && chown -R postgres:postgres "$PGDATA"--# Some defaults-ENV PG_BIN=/usr/lib/postgresql/${PG_VERSION}/bin-ENV PATH $PATH:$PG_BIN--EXPOSE 5432--HEALTHCHECK --interval=3s --timeout=3s --start-period=2s --retries=30 CMD gosu postgres pg_isready--COPY entrypoint.sh /-RUN chmod +x /entrypoint.sh-ENTRYPOINT ["/entrypoint.sh"]diff --git a/profile/demo-rpi.yml b/profile/demo-basic.ymlsimilarity index 67%rename from profile/demo-rpi.ymlrename to profile/demo-basic.ymlindex 52576cd71..61226a194 100644--- a/profile/demo-rpi.yml+++ b/profile/demo-basic.yml@@ -1,27 +1,46 @@#-# Demo setup of OpenRemote v3 on Rasperry Pi 3-#-# TODO: Needs updating for fast JDK9 aarch32 JVM, or JDK8 aarch64 JVM+# Demo setup of OpenRemote v3 with basic identity provider#version: '2.4'+volumes:+ postgresql-data:+ deployment-data:+services:+ # This service will only populate an empty volume on startup and then exit.+ # If the volume already contains data, it exits immediately.+ deployment:+ build: '../deployment'+ image: openremote/deployment:${DATE_TAG:-latest}+ volumes:+ - deployment-data:/deployment+proxy:extends:file: deploy.ymlservice: proxy+ depends_on:+ manager:+ condition: service_healthypostgresql:extends:file: deploy.ymlservice: postgresql+ volumes:+ - postgresql-data:/var/lib/postgresql/datamanager:extends:file: deploy.ymlservice: manager- image: openremote/rpi-manager:latest+ depends_on:+ postgresql:+ condition: service_healthy+ volumes:+ - deployment-data:/deploymentenvironment:# This switch can wipe all your Manager and Keycloak data! Typically you would only run the# stack once with this switch enabled to create the initial database and optionally importdiff --git a/profile/deploy.yml b/profile/deploy.ymlindex 4716043f2..477105668 100644--- a/profile/deploy.yml+++ b/profile/deploy.yml@@ -151,7 +151,7 @@ services:DATABASE_CONNECTION_URL: jdbc:postgresql://postgresql/openremote# The database connection settings, passwords should be changed in production!- DATABASE_USERNAME: openremote+ DATABASE_USERNAME: postgresDATABASE_PASSWORD: CHANGE_ME_DB_USER_PASSWORDDATABASE_MIN_POOL_SIZE: 5DATABASE_MAX_POOL_SIZE: 20@@ -279,7 +279,7 @@ services:DB_ADDR: postgresqlDB_PORT: 5432DB_DATABASE: openremote- DB_USER: openremote+ DB_USER: postgresDB_SCHEMA: publicDB_PASSWORD: CHANGE_ME_DB_USER_PASSWORDKEYCLOAK_USER: admin@@ -328,7 +328,7 @@ services:# then remove the variables and restart to preserve the stored data. It# doesn't hurt if you don't remove it, an existing will never be reconfigured.POSTGRES_DB: openremote- POSTGRES_USER: openremote+ POSTGRES_USER: postgres # 9.6 image doesn't work if we use a custom userPOSTGRES_PASSWORD: CHANGE_ME_DB_USER_PASSWORD# You can open an SQL console on a running container with:diff --git a/proxy/Dockerfile b/proxy/Dockerfileindex 778685f0a..4a6a604d7 100644--- a/proxy/Dockerfile+++ b/proxy/Dockerfile@@ -1,4 +1,4 @@-FROM debian:stretch+FROM debian:stretch-slimMAINTAINER [email protected]# Install utilities@@ -14,7 +14,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \RUN apt-get update \&& apt-get install -y --no-install-recommends \- certbot rsyslog cron inotify-tools make gcc g++ libreadline-dev libssl-dev libpcre3-dev libz-dev \+ curl certbot rsyslog cron inotify-tools make gcc g++ libreadline-dev libssl-dev libpcre3-dev libz-dev \&& rm -rf /var/lib/apt/lists/*ARG HA_PROXY_MINOR_VERSION=1.7diff --git a/proxy/rpi3.Dockerfile b/proxy/rpi3.Dockerfiledeleted file mode 100644index 11cf663f7..000000000--- a/proxy/rpi3.Dockerfile+++ /dev/null@@ -1,27 +0,0 @@-FROM openremote/rpi-raspbian:latest--ARG ACME_PLUGIN_VERSION=0.1.1--RUN [ "cross-build-start" ]--RUN apt-get update \- && apt-get install -y haproxy rsyslog inotify-tools \- && rm -rf /var/lib/apt/lists/* \- && rm /etc/haproxy/haproxy.cfg--RUN cd /etc/haproxy \- && curl -sSL https://github.com/janeczku/haproxy-acme-validation-plugin/archive/${ACME_PLUGIN_VERSION}.tar.gz -o acme-plugin.tar.gz \- && tar xvf acme-plugin.tar.gz --strip-components=1 --no-anchored acme-http01-webroot.lua \- && rm *.tar.gz && cd--RUN [ "cross-build-end" ]--ADD rsyslog.conf /etc/rsyslog.conf-ADD haproxy-init.cfg /etc/haproxy/haproxy-init.cfg-ADD demo /etc/haproxy/demo--EXPOSE 80 443--COPY entrypoint.sh /-RUN chmod +x /entrypoint.sh-ENTRYPOINT ["/entrypoint.sh"]\ No newline at end of file