From d6614ac52b3af6b8bca8c8c23438a020076faa33 Mon Sep 17 00:00:00 2001
From: Jacek Kowalski <Jacek@jacekk.info>
Date: Fri, 23 Nov 2018 16:47:45 +0000
Subject: [PATCH] Fixes for Rundeck 3.0 release

---
 Dockerfile |   15 +++++++--------
 run.sh     |   16 +++++++++-------
 README.md  |   27 +++++++++++++++++++++++++--
 3 files changed, 41 insertions(+), 17 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index d65633a..961f4a0 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,25 +1,24 @@
-FROM debian:stretch
+FROM openjdk:8-jre-slim
 
 ENV DEBIAN_FRONTEND noninteractive
+ENV RDECK_JVM_SETTINGS "-Xmx1024m -Xms256m -XX:MaxMetaspaceSize=256m -server"
 
 EXPOSE 4440
 
 ADD *-gpg.key /root/
 RUN apt-get -y update \
-	&& apt-get -y install gnupg \
 	&& apt-get -y upgrade \
-	&& echo 'deb http://httpredir.debian.org/debian stretch-backports main' > \
-		/etc/apt/sources.list.d/stretch-backports.list \
-	&& echo "deb http://dl.bintray.com/rundeck/rundeck-deb /" > /etc/apt/sources.list.d/rundeck.list \
+	&& apt-get -y install openssh-client wget gnupg \
+	&& echo "deb http://dl.bintray.com/rundeck/rundeck-deb /" \
+		> /etc/apt/sources.list.d/rundeck.list \
 	&& cat /root/*-gpg.key | apt-key add - \
 	&& apt-get -y update \
-	&& apt-get -y -t stretch-backports install \
-		openssh-client openjdk-8-jre-headless wget rundeck \
+	&& apt-get -y install rundeck \
 	&& apt-get -y clean \
 	&& rm -Rf /var/lib/apt/lists/*
 
 RUN mkdir /etc/rundeck-org \
-	&& mv /etc/rundeck/* /etc/rundeck-org/
+       && mv /etc/rundeck/* /etc/rundeck-org/
 
 ADD run.sh /
 CMD /run.sh
diff --git a/README.md b/README.md
index da47da9..57d422e 100644
--- a/README.md
+++ b/README.md
@@ -3,6 +3,12 @@
 This is a Docker image of Rundeck (http://rundeck.org)
 based on `debian:latest`
 
+## Upgrading
+
+Since version 3.0 /etc/rundeck/profile will be overriden!
+To customize JVM options use environment variable:
+`RDECK_JVM_SETTINGS`. See section "Configuration" below.
+
 ## Usage
 
 ```bash
@@ -29,7 +35,7 @@
 
 ### Local volumes
 
-You use local storage instead of data volumes:
+You can use local storage instead of data volumes:
 
 ```bash
 docker run -d --name=rundeck -p 4440:4440 \
@@ -80,4 +86,21 @@
 ## Configuration
 
 You can change Java system properties and JVM options by modifying
-`RDECK_JVM` property in `/etc/rundeck/profile` (which is persisted).
+`RDECK_JVM_SETTINGS` environment variable, which defaults to:
+
+```
+-Xmx1024m -Xms256m -XX:MaxMetaspaceSize=256m -server
+```
+
+Sample:
+
+```
+docker run -d --name=rundeck -p 4440:4440 \
+	-v /srv/rundeck/etc:/etc/rundeck \
+	-v /srv/rundeck/data:/var/lib/rundeck/data \
+	-v /srv/rundeck/logs:/var/lib/rundeck/logs \
+	-v /srv/rundeck/rundeck:/var/rundeck \
+	-v /srv/rundeck/ssh:/var/lib/rundeck/.ssh \
+	-e RDECK_JVM_SETTINGS="-Xms1024m -Xmx1024" \
+	jacekkow/rundeck
+```
diff --git a/run.sh b/run.sh
index 5c2ed07..52e0f8c 100755
--- a/run.sh
+++ b/run.sh
@@ -4,6 +4,15 @@
 	cp -Rfp /etc/rundeck-org/* /etc/rundeck/
 fi
 
+# Rundeck 3.0 - new property
+if ! grep -q -e "^rundeck.log4j.config.file" /etc/rundeck/rundeck-config.properties; then
+	echo "rundeck.log4j.config.file = /etc/rundeck/log4j.properties" \
+		>> /etc/rundeck/rundeck-config.properties
+fi
+
+# Rundeck 2.7, 3.0 - new profile
+cp -fp /etc/rundeck-org/profile /etc/rundeck/profile
+
 chown -Rf rundeck:rundeck /etc/rundeck /var/rundeck /var/lib/rundeck
 chmod -Rf o-rwx /etc/rundeck /var/rundeck /var/lib/rundeck
 
@@ -11,12 +20,5 @@
 chmod g+s,o+x /var/lib/rundeck/logs
 
 . /etc/rundeck/profile
-
-# Rundeck 2.6 to 2.7 migration - new profile file
-if [ -z "$rundeckd" ]; then
-	mv -f /etc/rundeck/profile /etc/rundeck/profile.pre-migration
-	cp -f /etc/rundeck-org/profile /etc/rundeck/profile
-	. /etc/rundeck/profile
-fi
 
 su rundeck -s /bin/bash -c "$rundeckd"

--
Gitblit v1.9.1