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 | 18 +++++++++++++++--- run.sh | 17 +++++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7f8fbbf..210cc95 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,18 +5,30 @@ RUN apt-get update \ && apt-get -y dist-upgrade \ && apt-get -y install --no-install-recommends \ - wget jsvc mongodb-server binutils unzip \ + 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 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 diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..1f48ed6 --- /dev/null +++ b/run.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +if [ -z "$JAVA_OPTS" ]; then + JAVA_OPTS="-Xmx1024m" +fi + +if [ ! -f /usr/lib/mfi/data/system.properties ]; then + cp -Rf /usr/lib/mfi/data-orig/. /usr/lib/mfi/data/ +fi + +if [ `id -u` -eq 0 ]; then + chown -Rf mfi:mfi /usr/lib/mfi/data + + exec sudo -u mfi java $JAVA_OPTS -jar /usr/lib/mfi/lib/ace.jar start +else + exec java $JAVA_OPTS -jar /usr/lib/mfi/lib/ace.jar start +fi -- Gitblit v1.9.1