Skip to content

Commit

Permalink
add gosu to dockerfile (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
legacycode authored and cniweb committed Jan 10, 2017
1 parent 46b9471 commit 33b9e86
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
19 changes: 13 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,22 @@ RUN \
apt-get update && \
apt-get install --no-install-recommends -y \
software-properties-common \
sudo \
unzip \
wget \
&& rm -rf /var/lib/apt/lists/*

# Install gosu
ENV GOSU_VERSION 1.7
RUN set -x \
&& wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture)" \
&& wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture).asc" \
&& export GNUPGHOME="$(mktemp -d)" \
&& gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \
&& gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \
&& rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc \
&& chmod +x /usr/local/bin/gosu \
&& gosu nobody true

# Install Oracle Java
RUN \
echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | debconf-set-selections && \
Expand All @@ -43,7 +54,6 @@ ENV JAVA_HOME /usr/lib/jvm/java-8-oracle
# Container base image puts dialout on group id 20, uucp on id 10
# GPIO Group for RPI access
RUN adduser --disabled-password --gecos '' --home ${APPDIR} openhab &&\
adduser openhab sudo &&\
groupadd -g 14 uucp2 &&\
groupadd -g 16 dialout2 &&\
groupadd -g 18 dialout3 &&\
Expand All @@ -55,9 +65,7 @@ RUN adduser --disabled-password --gecos '' --home ${APPDIR} openhab &&\
adduser openhab dialout2 &&\
adduser openhab dialout3 &&\
adduser openhab uucp3 &&\
adduser openhab gpio &&\

echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers.d/openhab
adduser openhab gpio

WORKDIR ${APPDIR}

Expand All @@ -76,7 +84,6 @@ ENTRYPOINT ["/entrypoint.sh"]

RUN chown -R openhab:openhab ${APPDIR}

USER openhab
# Expose volume with configuration and userdata dir
VOLUME ${APPDIR}/conf ${APPDIR}/userdata ${APPDIR}/addons
EXPOSE 8080 8443 5555
Expand Down
12 changes: 6 additions & 6 deletions files/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ IFS=$'\n\t'
if [ -z "$(ls -A "${APPDIR}/userdata")" ]; then
# Copy userdata dir
echo "No userdata found... initializing."
sudo cp -av "${APPDIR}/userdata.dist/." "${APPDIR}/userdata/"
cp -av "${APPDIR}/userdata.dist/." "${APPDIR}/userdata/"
fi

if [ -z "$(ls -A "${APPDIR}/conf")" ]; then
# Copy userdata dir
echo "No configuration found... initializing."
sudo cp -av "${APPDIR}/conf.dist/." "${APPDIR}/conf/"
cp -av "${APPDIR}/conf.dist/." "${APPDIR}/conf/"
fi

# Prettier interface
if [ "$1" = 'server' ] || [ "$1" = 'openhab' ]; then
eval "${APPDIR}/start.sh"
gosu openhab "${APPDIR}/start.sh"
elif [ "$1" = 'debug' ]; then
eval "${APPDIR}/start_debug.sh"
gosu openhab "${APPDIR}/start_debug.sh"
elif [ "$1" = 'console' ] || [ "$1" = 'shell' ]; then
exec "${APPDIR}/runtime/bin/client"
gosu openhab "${APPDIR}/runtime/bin/client"
else
exec "$@"
gosu openhab "$@"
fi

0 comments on commit 33b9e86

Please sign in to comment.