diff --git a/Dockerfile.arm7hf b/Dockerfile.arm7hf new file mode 100644 index 00000000..33b0e74b --- /dev/null +++ b/Dockerfile.arm7hf @@ -0,0 +1,35 @@ +# openhab image for armv7hf +FROM cyberkov/openhab-base:arm7hf + +ARG DOWNLOAD_URL="https://openhab.ci.cloudbees.com/job/openHAB-Distribution/lastSuccessfulBuild/artifact/distributions/openhab-offline/target/openhab-offline-2.0.0-SNAPSHOT.zip" +ENV APPDIR="/openhab" +RUN [ "cross-build-start" ] + +# Add openhab user +RUN adduser --disabled-password --gecos '' --home ${APPDIR} openhab &&\ + adduser openhab sudo &&\ + adduser openhab dialout &&\ + echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers.d/openhab + +WORKDIR ${APPDIR} + +RUN \ + wget -nv -O /tmp/openhab.zip ${DOWNLOAD_URL} &&\ + unzip -q /tmp/openhab.zip -d ${APPDIR} &&\ + rm /tmp/openhab.zip + +RUN mkdir -p ${APPDIR}/userdata/logs && touch ${APPDIR}/userdata/logs/openhab.log + +# Copy directories for host volumes +RUN cp -a /openhab/userdata /openhab/userdata.dist && \ + cp -a /openhab/conf /openhab/conf.dist +COPY ./entrypoint.sh / +ENTRYPOINT ["/entrypoint.sh"] + +RUN chown -R openhab:openhab ${APPDIR} +RUN [ "cross-build-end" ] +USER openhab +# Expose volume with configuration and userdata dir +VOLUME ${APPDIR}/conf ${APPDIR}/userdata +EXPOSE 8080 8443 5555 +CMD server diff --git a/Dockerfile.x86 b/Dockerfile.x86 new file mode 100644 index 00000000..cbf52c03 --- /dev/null +++ b/Dockerfile.x86 @@ -0,0 +1,33 @@ +# openhab image for x86 +FROM cyberkov/openhab-base:latest + +ARG DOWNLOAD_URL="https://openhab.ci.cloudbees.com/job/openHAB-Distribution/lastSuccessfulBuild/artifact/distributions/openhab-offline/target/openhab-offline-2.0.0-SNAPSHOT.zip" +ENV APPDIR="/openhab" + +# Add openhab user +RUN adduser --disabled-password --gecos '' --home ${APPDIR} openhab &&\ + adduser openhab sudo &&\ + adduser openhab dialout &&\ + echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers.d/openhab + +WORKDIR ${APPDIR} + +RUN \ + wget -nv -O /tmp/openhab.zip ${DOWNLOAD_URL} &&\ + unzip -q /tmp/openhab.zip -d ${APPDIR} &&\ + rm /tmp/openhab.zip + +RUN mkdir -p ${APPDIR}/userdata/logs && touch ${APPDIR}/userdata/logs/openhab.log + +# Copy directories for host volumes +RUN cp -a /openhab/userdata /openhab/userdata.dist && \ + cp -a /openhab/conf /openhab/conf.dist +COPY ./entrypoint.sh / +ENTRYPOINT ["/entrypoint.sh"] + +RUN chown -R openhab:openhab ${APPDIR} +USER openhab +# Expose volume with configuration and userdata dir +VOLUME ${APPDIR}/conf ${APPDIR}/userdata +EXPOSE 8080 8443 5555 +CMD server diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 00000000..26f5e7d5 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,25 @@ +#!/bin/bash -x +set -e + +# Initialize empty host volumes +if [ -z "$(ls -A "/openhab/userdata")" ]; then + # Copy userdata dir + echo "No userdata found... initializing." + sudo cp -av /openhab/userdata.dist/. /openhab/userdata/ +fi + +if [ -z "$(ls -A "/openhab/conf")" ]; then + # Copy userdata dir + echo "No configuration found... initializing." + sudo cp -av /openhab/conf.dist/. /openhab/conf/ +fi + +# Prettier interface +if [ "$1" = 'server' ] || [ "$1" = 'openhab' ]; then + eval /openhab/start.sh +elif [ "$1" = 'debug' ]; then + eval /openhab/start_debug.sh +else + exec "$@" +fi +