Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Switched to Debian base image because JVM leaks memory on CentOS glibc

Christian Bauerf3bfece851d0
diff --git a/README.md b/README.md
index b829c5eda..67f24d1ca 100644
--- a/README.md
+++ b/README.md
@@ -67,16 +67,17 @@ Perform a clean build, delete all data volumes (!), and run all tests before com
docker volume prune
docker-compose -p openremote -f profile/dev-testing.yml up -d
./gradlew clean build installDist
+docker-compose -p openremote -f profile/dev-testing.yml down
docker build -t openremote/proxy:latest haproxy
docker build -t openremote/postgresql:latest postgresql
docker build -t openremote/keycloak:latest keycloak
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):
```
+docker login
docker push openremote/proxy:latest
docker push openremote/postgresql:latest
docker push openremote/keycloak:latest
diff --git a/keycloak/Dockerfile b/keycloak/Dockerfile
index befd22208..286ec01a6 100644
--- a/keycloak/Dockerfile
+++ b/keycloak/Dockerfile
@@ -1,19 +1,129 @@
-FROM jboss/keycloak:2.5.5.Final
+FROM debian:stretch
+MAINTAINER [email protected]
+
+# Install curl, wget, ca-certificates, procps
+RUN apt-get update && apt-get install -y --no-install-recommends \
+ 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
+
+ENV JAVA_VERSION 8u151
+ENV JAVA_DEBIAN_VERSION 8u151-b12-1~deb9u1
+
+# see https://bugs.debian.org/775775
+# and https://github.com/docker-library/java/issues/19#issuecomment-70546872
+ENV CA_CERTIFICATES_JAVA_VERSION 20170531+nmu1
+
+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="$JAVA_DEBIAN_VERSION" \
+ ca-certificates-java="$CA_CERTIFICATES_JAVA_VERSION" \
+ ; \
+ 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'
+
+# see CA_CERTIFICATES_JAVA_VERSION notes above
+RUN /var/lib/dpkg/info/ca-certificates-java.postinst configure
+
+# Install dependencies for JBoss AS
+RUN apt-get update \
+ && apt-get install -y --no-install-recommends \
+ jq xmlstarlet libsaxon-java unzip bsdtar bzip2 xz-utils \
+ && rm -rf /var/lib/apt/lists/*
+
+# Create a user and group used to launch processes
+# The user ID 1000 is the default for the first "regular" user on Fedora/RHEL,
+# so there is a high chance that this ID will be equal to the current user
+# making it easier to use volumes (no permission issues)
+RUN groupadd -r jboss -g 1000 && useradd -u 1000 -r -g jboss -m -d /opt/jboss -s /sbin/nologin -c "JBoss user" jboss && \
+ chmod 755 /opt/jboss
+
+# Set the working directory to jboss' user home directory
+WORKDIR /opt/jboss
+ADD docker-entrypoint.sh /opt/jboss/
+RUN chmod +x /opt/jboss/docker-entrypoint.sh
+ENV JBOSS_HOME /opt/jboss/keycloak
+
+# Switch to jboss user
+USER jboss
+
+ENV KEYCLOAK_VERSION 2.5.5.Final
+ENV POSTGRESQL_DRIVER_VERSION 42.1.4
+
+# Enables signals getting passed from startup script to JVM
+# ensuring clean shutdown when container is stopped.
+ENV LAUNCH_JBOSS_IN_BACKGROUND 1
+
+RUN curl -L https://downloads.jboss.org/keycloak/$KEYCLOAK_VERSION/keycloak-$KEYCLOAK_VERSION.tar.gz | \
+ tar zx && mv /opt/jboss/keycloak-$KEYCLOAK_VERSION $JBOSS_HOME
+
+ADD setLogLevel.xsl /opt/jboss/keycloak/
+RUN java -jar /usr/share/java/saxon.jar \
+ -o /opt/jboss/keycloak/standalone/configuration/standalone.xml \
+ /opt/jboss/keycloak/standalone/configuration/standalone.xml \
+ /opt/jboss/keycloak/setLogLevel.xsl
ADD changeDatabase.xsl /opt/jboss/keycloak/
-RUN java -jar /usr/share/java/saxon.jar -s:/opt/jboss/keycloak/standalone/configuration/standalone.xml -xsl:/opt/jboss/keycloak/changeDatabase.xsl -o:/opt/jboss/keycloak/standalone/configuration/standalone.xml; java -jar /usr/share/java/saxon.jar -s:/opt/jboss/keycloak/standalone/configuration/standalone-ha.xml -xsl:/opt/jboss/keycloak/changeDatabase.xsl -o:/opt/jboss/keycloak/standalone/configuration/standalone-ha.xml; rm /opt/jboss/keycloak/changeDatabase.xsl
-RUN mkdir -p /opt/jboss/keycloak/modules/system/layers/base/org/postgresql/jdbc/main
-RUN curl -o /opt/jboss/keycloak/modules/system/layers/base/org/postgresql/jdbc/main/postgresql-jdbc.jar http://repo1.maven.org/maven2/org/postgresql/postgresql/9.4.1209/postgresql-9.4.1209.jar 2>/dev/null
+RUN java -jar /usr/share/java/saxon.jar \
+ -o /opt/jboss/keycloak/standalone/configuration/standalone.xml \
+ /opt/jboss/keycloak/standalone/configuration/standalone.xml \
+ /opt/jboss/keycloak/changeDatabase.xsl && \
+ java -jar /usr/share/java/saxon.jar \
+ -o /opt/jboss/keycloak/standalone/configuration/standalone-ha.xml \
+ /opt/jboss/keycloak/standalone/configuration/standalone-ha.xml \
+ /opt/jboss/keycloak/changeDatabase.xsl && \
+ rm /opt/jboss/keycloak/changeDatabase.xsl
+RUN mkdir -p /opt/jboss/keycloak/modules/system/layers/base/org/postgresql/jdbc/main && \
+ curl -o /opt/jboss/keycloak/modules/system/layers/base/org/postgresql/jdbc/main/postgresql-jdbc.jar \
+ http://repo1.maven.org/maven2/org/postgresql/postgresql/${POSTGRESQL_DRIVER_VERSION}/postgresql-${POSTGRESQL_DRIVER_VERSION}.jar 2>/dev/null
ADD module.xml /opt/jboss/keycloak/modules/system/layers/base/org/postgresql/jdbc/main/
ADD setProxyForwarding.xsl /opt/jboss/keycloak/
-RUN java -jar /usr/share/java/saxon.jar -s:/opt/jboss/keycloak/standalone/configuration/standalone.xml -xsl:/opt/jboss/keycloak/setProxyForwarding.xsl -o:/opt/jboss/keycloak/standalone/configuration/standalone.xml
-
-ADD theme /opt/jboss/keycloak/themes/openremote
+RUN java -jar /usr/share/java/saxon.jar \
+ -o /opt/jboss/keycloak/standalone/configuration/standalone.xml \
+ /opt/jboss/keycloak/standalone/configuration/standalone.xml \
+ /opt/jboss/keycloak/setProxyForwarding.xsl
RUN rm /opt/jboss/keycloak/*.xsl
HEALTHCHECK --interval=3s --timeout=3s --start-period=2s --retries=30 CMD curl --fail http://localhost:8080/auth || exit 1
+EXPOSE 8080
+
ENTRYPOINT ["/opt/jboss/docker-entrypoint.sh"]
-CMD ["-b", "0.0.0.0"]
\ No newline at end of file
+CMD ["-b", "0.0.0.0"]
+
+ADD theme /opt/jboss/keycloak/themes/openremote
diff --git a/keycloak/dev.Dockerfile b/keycloak/dev.Dockerfile
index c3f3992c9..6ba0058db 100644
--- a/keycloak/dev.Dockerfile
+++ b/keycloak/dev.Dockerfile
@@ -1,24 +1,141 @@
-FROM jboss/keycloak:2.5.5.Final
+FROM debian:stretch
+MAINTAINER [email protected]
+
+# Install curl, wget, ca-certificates, procps
+RUN apt-get update && apt-get install -y --no-install-recommends \
+ 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
+
+ENV JAVA_VERSION 8u151
+ENV JAVA_DEBIAN_VERSION 8u151-b12-1~deb9u1
+
+# see https://bugs.debian.org/775775
+# and https://github.com/docker-library/java/issues/19#issuecomment-70546872
+ENV CA_CERTIFICATES_JAVA_VERSION 20170531+nmu1
+
+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="$JAVA_DEBIAN_VERSION" \
+ ca-certificates-java="$CA_CERTIFICATES_JAVA_VERSION" \
+ ; \
+ 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'
+
+# see CA_CERTIFICATES_JAVA_VERSION notes above
+RUN /var/lib/dpkg/info/ca-certificates-java.postinst configure
+
+# Install dependencies for JBoss AS
+RUN apt-get update \
+ && apt-get install -y --no-install-recommends \
+ jq xmlstarlet libsaxon-java unzip bsdtar bzip2 xz-utils \
+ && rm -rf /var/lib/apt/lists/*
+
+# Create a user and group used to launch processes
+# The user ID 1000 is the default for the first "regular" user on Fedora/RHEL,
+# so there is a high chance that this ID will be equal to the current user
+# making it easier to use volumes (no permission issues)
+RUN groupadd -r jboss -g 1000 && useradd -u 1000 -r -g jboss -m -d /opt/jboss -s /sbin/nologin -c "JBoss user" jboss && \
+ chmod 755 /opt/jboss
+
+# Set the working directory to jboss' user home directory
+WORKDIR /opt/jboss
+ADD docker-entrypoint.sh /opt/jboss/
+RUN chmod +x /opt/jboss/docker-entrypoint.sh
+ENV JBOSS_HOME /opt/jboss/keycloak
+
+# Switch to jboss user
+USER jboss
+
+ENV KEYCLOAK_VERSION 2.5.5.Final
+ENV POSTGRESQL_DRIVER_VERSION 42.1.4
+
+# Enables signals getting passed from startup script to JVM
+# ensuring clean shutdown when container is stopped.
+ENV LAUNCH_JBOSS_IN_BACKGROUND 1
+
+RUN curl -L https://downloads.jboss.org/keycloak/$KEYCLOAK_VERSION/keycloak-$KEYCLOAK_VERSION.tar.gz | \
+ tar zx && mv /opt/jboss/keycloak-$KEYCLOAK_VERSION $JBOSS_HOME
+
+ADD setLogLevel.xsl /opt/jboss/keycloak/
+RUN java -jar /usr/share/java/saxon.jar \
+ -o /opt/jboss/keycloak/standalone/configuration/standalone.xml \
+ /opt/jboss/keycloak/standalone/configuration/standalone.xml \
+ /opt/jboss/keycloak/setLogLevel.xsl
ADD changeDatabase.xsl /opt/jboss/keycloak/
-RUN java -jar /usr/share/java/saxon.jar -s:/opt/jboss/keycloak/standalone/configuration/standalone.xml -xsl:/opt/jboss/keycloak/changeDatabase.xsl -o:/opt/jboss/keycloak/standalone/configuration/standalone.xml; java -jar /usr/share/java/saxon.jar -s:/opt/jboss/keycloak/standalone/configuration/standalone-ha.xml -xsl:/opt/jboss/keycloak/changeDatabase.xsl -o:/opt/jboss/keycloak/standalone/configuration/standalone-ha.xml; rm /opt/jboss/keycloak/changeDatabase.xsl
-RUN mkdir -p /opt/jboss/keycloak/modules/system/layers/base/org/postgresql/jdbc/main
-RUN curl -o /opt/jboss/keycloak/modules/system/layers/base/org/postgresql/jdbc/main/postgresql-jdbc.jar http://repo1.maven.org/maven2/org/postgresql/postgresql/9.4.1209/postgresql-9.4.1209.jar 2>/dev/null
+RUN java -jar /usr/share/java/saxon.jar \
+ -o /opt/jboss/keycloak/standalone/configuration/standalone.xml \
+ /opt/jboss/keycloak/standalone/configuration/standalone.xml \
+ /opt/jboss/keycloak/changeDatabase.xsl && \
+ java -jar /usr/share/java/saxon.jar \
+ -o /opt/jboss/keycloak/standalone/configuration/standalone-ha.xml \
+ /opt/jboss/keycloak/standalone/configuration/standalone-ha.xml \
+ /opt/jboss/keycloak/changeDatabase.xsl && \
+ rm /opt/jboss/keycloak/changeDatabase.xsl
+RUN mkdir -p /opt/jboss/keycloak/modules/system/layers/base/org/postgresql/jdbc/main && \
+ curl -o /opt/jboss/keycloak/modules/system/layers/base/org/postgresql/jdbc/main/postgresql-jdbc.jar \
+ http://repo1.maven.org/maven2/org/postgresql/postgresql/${POSTGRESQL_DRIVER_VERSION}/postgresql-${POSTGRESQL_DRIVER_VERSION}.jar 2>/dev/null
ADD module.xml /opt/jboss/keycloak/modules/system/layers/base/org/postgresql/jdbc/main/
ADD setProxyForwarding.xsl /opt/jboss/keycloak/
-RUN java -jar /usr/share/java/saxon.jar -s:/opt/jboss/keycloak/standalone/configuration/standalone.xml -xsl:/opt/jboss/keycloak/setProxyForwarding.xsl -o:/opt/jboss/keycloak/standalone/configuration/standalone.xml
-
-ADD devModeConfig.xsl /opt/jboss/keycloak/
-RUN java -jar /usr/share/java/saxon.jar -s:/opt/jboss/keycloak/standalone/configuration/standalone.xml -xsl:/opt/jboss/keycloak/devModeConfig.xsl -o:/opt/jboss/keycloak/standalone/configuration/standalone.xml
-
-# This produces a lot of log output, only enable when you must log all HTTP traffic into Keycloak
-# ADD enableRequestDumping.xsl /opt/jboss/keycloak/
-# RUN java -jar /usr/share/java/saxon.jar -s:/opt/jboss/keycloak/standalone/configuration/standalone.xml -xsl:/opt/jboss/keycloak/enableRequestDumping.xsl -o:/opt/jboss/keycloak/standalone/configuration/standalone.xml
+RUN java -jar /usr/share/java/saxon.jar \
+ -o /opt/jboss/keycloak/standalone/configuration/standalone.xml \
+ /opt/jboss/keycloak/standalone/configuration/standalone.xml \
+ /opt/jboss/keycloak/setProxyForwarding.xsl
RUN rm /opt/jboss/keycloak/*.xsl
HEALTHCHECK --interval=3s --timeout=3s --start-period=2s --retries=30 CMD curl --fail http://localhost:8080/auth || exit 1
+EXPOSE 8080
+
ENTRYPOINT ["/opt/jboss/docker-entrypoint.sh"]
-CMD ["-b", "0.0.0.0"]
\ No newline at end of file
+CMD ["-b", "0.0.0.0"]
+
+ADD devModeConfig.xsl /opt/jboss/keycloak/
+RUN java -jar /usr/share/java/saxon.jar \
+ -o /opt/jboss/keycloak/standalone/configuration/standalone.xml \
+ /opt/jboss/keycloak/standalone/configuration/standalone.xml \
+ /opt/jboss/keycloak/devModeConfig.xsl
+
+# This produces a lot of log output, only enable when you must log all HTTP traffic into Keycloak
+#ADD enableRequestDumping.xsl /opt/jboss/keycloak/
+#RUN java -jar /usr/share/java/saxon.jar \
+# -o /opt/jboss/keycloak/standalone/configuration/standalone.xml \
+# /opt/jboss/keycloak/standalone/configuration/standalone.xml \
+# /opt/jboss/keycloak/enableRequestDumping.xsl
+
diff --git a/keycloak/docker-entrypoint.sh b/keycloak/docker-entrypoint.sh
new file mode 100644
index 000000000..55e3eaa6d
--- /dev/null
+++ b/keycloak/docker-entrypoint.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+if [ $KEYCLOAK_USER ] && [ $KEYCLOAK_PASSWORD ]; then
+ keycloak/bin/add-user-keycloak.sh --user $KEYCLOAK_USER --password $KEYCLOAK_PASSWORD
+fi
+
+exec /opt/jboss/keycloak/bin/standalone.sh $@
+exit $?
\ No newline at end of file
diff --git a/keycloak/setLogLevel.xsl b/keycloak/setLogLevel.xsl
new file mode 100644
index 000000000..6b7d72cbf
--- /dev/null
+++ b/keycloak/setLogLevel.xsl
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsl:stylesheet version="2.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:log="urn:jboss:domain:logging:3.0">
+
+ <xsl:output method="xml" indent="yes"/>
+
+ <xsl:template match="//log:subsystem">
+ <xsl:copy>
+ <xsl:apply-templates select="node()|@*"/>
+ <log:logger category="org.keycloak">
+ <log:level>
+ <xsl:attribute name="name">${env.KEYCLOAK_LOGLEVEL:INFO}</xsl:attribute>
+ </log:level>
+ </log:logger>
+ </xsl:copy>
+ </xsl:template>
+
+ <xsl:template match="@*|node()">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()"/>
+ </xsl:copy>
+ </xsl:template>
+
+</xsl:stylesheet>
diff --git a/manager/Dockerfile b/manager/Dockerfile
index 1d52ee2ac..6dcf21001 100644
--- a/manager/Dockerfile
+++ b/manager/Dockerfile
@@ -1,7 +1,63 @@
-FROM centos:7
+FROM debian:stretch
+MAINTAINER [email protected]
+
+# Install curl, wget, ca-certificates, procps
+RUN apt-get update && apt-get install -y --no-install-recommends \
+ 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
+
+ENV JAVA_VERSION 8u151
+ENV JAVA_DEBIAN_VERSION 8u151-b12-1~deb9u1
+
+# see https://bugs.debian.org/775775
+# and https://github.com/docker-library/java/issues/19#issuecomment-70546872
+ENV CA_CERTIFICATES_JAVA_VERSION 20170531+nmu1
+
+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="$JAVA_DEBIAN_VERSION" \
+ ca-certificates-java="$CA_CERTIFICATES_JAVA_VERSION" \
+ ; \
+ 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'
+
+# see CA_CERTIFICATES_JAVA_VERSION notes above
+RUN /var/lib/dpkg/info/ca-certificates-java.postinst configure
-RUN yum update -y && yum -y install java-1.8.0-openjdk-devel && yum clean all
-ENV JAVA_HOME /usr/lib/jvm/java
ENV JAVA_OPTS -Xmx1g
ENV MANAGER_DOCROOT webapp
diff --git a/manager/server/src/main/resources/org/openremote/manager/server/setup/database/V20171031_01__Schema.sql b/manager/server/src/main/resources/org/openremote/manager/server/setup/database/V20171031_01__Schema.sql
index a802b6e66..e9da5d017 100644
--- a/manager/server/src/main/resources/org/openremote/manager/server/setup/database/V20171031_01__Schema.sql
+++ b/manager/server/src/main/resources/org/openremote/manager/server/setup/database/V20171031_01__Schema.sql
@@ -3,7 +3,6 @@
*/
create extension if not exists POSTGIS;
create extension if not exists POSTGIS_TOPOLOGY;
-create extension if not exists FUZZYSTRMATCH;
/*
############################# SEQUENCES #############################
diff --git a/manager/server/src/main/resources/org/openremote/manager/server/setup/database/beforeClean.sql b/manager/server/src/main/resources/org/openremote/manager/server/setup/database/beforeClean.sql
index a44e44770..3d8325aa2 100644
--- a/manager/server/src/main/resources/org/openremote/manager/server/setup/database/beforeClean.sql
+++ b/manager/server/src/main/resources/org/openremote/manager/server/setup/database/beforeClean.sql
@@ -1,3 +1,2 @@
drop extension if exists POSTGIS cascade;
-drop extension if exists CITEXT cascade;
-drop extension if exists FUZZYSTRMATCH cascade;
\ No newline at end of file
+drop extension if exists CITEXT cascade;
\ No newline at end of file
diff --git a/postgresql/Dockerfile b/postgresql/Dockerfile
index de27bf167..17af94dad 100644
--- a/postgresql/Dockerfile
+++ b/postgresql/Dockerfile
@@ -1,42 +1,45 @@
-FROM centos:7
-
-ENV CENTOS_VERSION=7 \
- PG_VERSION=9.6 \
- PG_VERSION_MINOR=3 \
- PG_NODOT=96 \
- POSTGIS_VERSION=23 \
+FROM debian:stretch
+MAINTAINER [email protected]
+
+# Install curl, wget, ca-certificates, procps
+RUN apt-get update && apt-get install -y --no-install-recommends \
+ procps \
+ ca-certificates \
+ curl \
+ wget \
+ && rm -rf /var/lib/apt/lists/*
+
+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 from Postgres website
-RUN cd /tmp && \
- yum install -y epel-release && \
- curl -L -o pgdg.rpm https://yum.postgresql.org/${PG_VERSION}/redhat/rhel-${CENTOS_VERSION}-x86_64/pgdg-redhat${PG_NODOT}-${PG_VERSION}-${PG_VERSION_MINOR}.noarch.rpm && \
- yum localinstall -y pgdg.rpm && \
- yum upgrade -y && \
- yum install -y \
- postgis${POSTGIS_VERSION}_${PG_NODOT} \
- postgis${POSTGIS_VERSION}_${PG_NODOT}-client \
- postgis${POSTGIS_VERSION}_${PG_NODOT}-utils \
- pgrouting_${PG_NODOT} \
- postgresql${PG_NODOT}-contrib \
- postgresql${PG_NODOT}-server
+# Install postgresql/postgis
+RUN apt-get update \
+ && apt-get install -y --no-install-recommends \
+ locales \
+ 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-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/pgsql-${PG_VERSION}/bin
+ENV PG_BIN=/usr/lib/postgresql/${PG_VERSION}/bin
ENV PATH $PATH:$PG_BIN
-ENV LANG en_US.utf8
EXPOSE 5432
diff --git a/profile/demo.yml b/profile/demo.yml
index 67403b64e..7eb3157df 100644
--- a/profile/demo.yml
+++ b/profile/demo.yml
@@ -42,7 +42,7 @@ version: '2.2'
# If you enable volume mappings in services, you need this. Otherwise, remove the volumes
volumes:
#proxy-data:
- manager-data:
+ #manager-data:
postgresql-data:
services:
@@ -74,20 +74,23 @@ services:
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.
+ # The ../deployment directory is baked into the managers image. Here you can
+ # override it with either a (different) host-mapped directory or a named data volume.
+
+ # Use local deployment data in host-mapped directory for easy development.
# - ${DEPLOYMENT_DIRECTORY:-../deployment}/manager:/deployment
# Use a named volume. When the volume is empty on startup, the files in the manager
# image's /deployment directory will be copied into the empty volume, thus
# giving you a default configuration to modify. Access the volume with:
#
- # docker run --rm -it -v openremote_manager-data:/deployment centos:7 /bin/bash
+ # docker run --rm -it -v openremote_manager-data:/deployment debian:stretch /bin/bash
# > ls -la /deployment
#
# To use a volume, enable this:
#
# - manager-data:/deployment
+
environment:
# This switch can wipe all your Manager and Keycloak data, this is the factory reset!
SETUP_WIPE_CLEAN_INSTALL: 'true'
@@ -116,9 +119,11 @@ services:
file: deploy.yml
service: postgresql
volumes:
- # Store data either in host-mapped directory or a named Docker volume
- #
+ # Store data either in host-mapped directory or a named Docker volume.
+
+ # By default, we use a named volume to avoid permission problems with PostgreSQL.
+ - postgresql-data:/deployment
+
# If you use a directory, it must be owned by user:group 5432:5432 and mode 700!
#
# - ${DEPLOYMENT_DIRECTORY:-../deployment}/postgresql:/deployment
- - postgresql-data:/deployment
diff --git a/profile/deploy.yml b/profile/deploy.yml
index a17e31b56..1803783db 100644
--- a/profile/deploy.yml
+++ b/profile/deploy.yml
@@ -55,6 +55,10 @@ services:
- "80:80"
- "443:443"
+ # Resource limits
+ mem_limit: 50m
+ memswap_limit: 50m
+
# Configure logging of the container
logging:
options:
@@ -184,8 +188,17 @@ services:
# unless you want to deploy a modified version of the Manager UI.
# MANAGER_DOCROOT: 'manager/client/src/main/webapp'
- # Custom JVM options (default max heap size is 1GB)
- # JAVA_OPTS: '-Xmx1g -XX:+PrintGCDetails'
+ # Custom JVM options (increase heap size if required)
+ JAVA_OPTS: '-Xms400m -Xmx400m
+ -XX:CompressedClassSpaceSize=25m -XX:MaxMetaspaceSize=150m
+ -XX:InitialCodeCacheSize=25m -XX:ReservedCodeCacheSize=25m
+ -XX:MaxDirectMemorySize=25m
+ -XX:NativeMemoryTracking=summary
+ -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/javadump.core.hprof'
+
+ # Resource limits
+ mem_limit: 700m
+ memswap_limit: 700m
# Configure logging of the container, see deployment/logging.properties
logging:
@@ -220,6 +233,19 @@ services:
POSTGRES_USER: openremote
POSTGRES_PASSWORD: CHANGE_ME_DB_USER_PASSWORD
+ # Custom JVM options (increase heap size if required)
+ JAVA_OPTS: '-Xms300m -Xmx300m
+ -XX:CompressedClassSpaceSize=25m -XX:MaxMetaspaceSize=150m
+ -XX:InitialCodeCacheSize=25m -XX:ReservedCodeCacheSize=25m
+ -XX:MaxDirectMemorySize=25m
+ -XX:NativeMemoryTracking=summary
+ -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/javadump.core.hprof
+ -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true'
+
+ # Resource limits
+ mem_limit: 600m
+ memswap_limit: 600m
+
# Configure logging of the container
logging:
options:
@@ -248,6 +274,10 @@ services:
# You can open an SQL console on a running container with:
# docker exec -it <container ID> psql -U openremote
+ # Resource limits
+ mem_limit: 300m
+ memswap_limit: 300m
+
# Configure logging of the container
logging:
options:
diff --git a/proxy/Dockerfile b/proxy/Dockerfile
index 0342ab7ca..0755adbf3 100644
--- a/proxy/Dockerfile
+++ b/proxy/Dockerfile
@@ -1,11 +1,21 @@
-FROM centos:7
-
-RUN yum update -y && yum -y install epel-release && \
- yum -y install rsyslog inotify-tools make gcc pcre-devel openssl-devel readline-devel certbot cronie && \
- yum clean all
+FROM debian:stretch
+MAINTAINER [email protected]
+
+# Install curl, wget, ca-certificates, procps
+RUN apt-get update && apt-get install -y --no-install-recommends \
+ procps \
+ ca-certificates \
+ curl \
+ wget \
+ && rm -rf /var/lib/apt/lists/*
+
+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 \
+ && rm -rf /var/lib/apt/lists/*
ARG HA_PROXY_MINOR_VERSION=1.7
-ARG HA_PROXY_VERSION=1.7.5
+ARG HA_PROXY_VERSION=1.7.9
ARG LUA_VERSION=5.3.4
ARG ACME_PLUGIN_VERSION=0.1.1
ARG DOMAINNAME
@@ -32,6 +42,8 @@ RUN mkdir /etc/haproxy && cd /etc/haproxy \
&& tar xvf acme-plugin.tar.gz --strip-components=1 --no-anchored acme-http01-webroot.lua \
&& rm *.tar.gz && cd
+RUN apt-get purge --auto-remove -y make gcc g++ libreadline-dev libssl-dev libpcre3-dev libz-dev
+
RUN mkdir /opt/selfsigned
ADD rsyslog.conf /etc/rsyslog.conf
diff --git a/proxy/entrypoint.sh b/proxy/entrypoint.sh
index 586718be1..a6587f7e5 100644
--- a/proxy/entrypoint.sh
+++ b/proxy/entrypoint.sh
@@ -63,7 +63,7 @@ function check_proxy {
function run_proxy {
# Start rsyslogd
- rsyslogd
+ service rsyslog start
check_proxy
@@ -378,7 +378,7 @@ function cron_auto_renewal {
# Start crond if not running
if ! [ -f /var/run/crond.pid ]; then
log_info "CRON daemon starting..."
- crond
+ service cron start
log_info "CRON daemon started"
fi
}