From 294fcc89762a47a166947dc8d3d4360713ba21dc Mon Sep 17 00:00:00 2001
From: Jacek Kowalski <Jacek@jacekk.info>
Date: Sun, 13 May 2018 16:58:34 +0000
Subject: [PATCH] Set mFi to initialize on first run with empty data dir

---
 Dockerfile |   27 ++++++++++++++++++++-------
 1 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index 749c34a..210cc95 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,21 +1,34 @@
-FROM debian
-MAINTAINER Jacek Kowalski <Jacek@jacekk.info>
+FROM openjdk:7-jre-slim
 
 ENV MFI_VERSION 2.1.11
 
 RUN apt-get update \
 	&& apt-get -y dist-upgrade \
-	&& apt-get -y install wget jsvc openjdk-7-jre-headless mongodb-server binutils unzip \
-	&& apt-get -y clean
+	&& apt-get -y install --no-install-recommends \
+		wget jsvc mongodb-server binutils procps unzip \
+	&& apt-get -y clean \
+	&& rm -Rf /var/lib/apt/lists/*
 
 RUN cd /tmp \
 	&& wget "http://dl.ubnt.com/mfi/${MFI_VERSION}/mFi.unix.zip" \
 	&& unzip mFi.unix.zip \
-	&& mv /tmp/mFi /usr/lib/mfi
+	&& rm mFi.unix.zip \
+	&& mv /tmp/mFi /usr/lib/mfi \
+	&& cp -Rf /usr/lib/mfi/data /usr/lib/mfi/data-orig \
+	&& groupadd -r -g 500 mfi \
+	&& useradd -r -d /usr/lib/mfi -u 500 -g 500 mfi \
+	&& mkdir -p /var/lib/mfi \
+	&& chown -Rf mfi:mfi /usr/lib/mfi /var/lib/mfi
 
-EXPOSE 8080 8081 8443 8843 8880
+EXPOSE 6080 6443
 
 VOLUME /usr/lib/mfi/data
 
 WORKDIR /var/lib/mfi
-CMD ["/usr/bin/java", "-Xmx1024M", "-jar", "/usr/lib/mfi/lib/ace.jar", "start"]
+COPY run.sh /run.sh
+CMD /run.sh
+
+USER mfi
+
+HEALTHCHECK --start-period=3m CMD wget -q -O /dev/null --no-check-certificate \
+	https://127.0.0.1:6443/login

--
Gitblit v1.9.1