Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ RUN set -ex \
&& pip3 install setuptools requests pyserial

VOLUME /opt/domoticz/userdata
VOLUME /opt/domoticz/www/templates

EXPOSE 8080
EXPOSE 443
Expand All @@ -69,5 +70,8 @@ COPY customstart.sh /opt/domoticz/customstart.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh \
&& ln -s usr/local/bin/docker-entrypoint.sh / # backwards compat

# squirrel the web templates (used during self-repair by docker-entrypoint.sh)
RUN cp -a /opt/domoticz/www/templates /opt/domoticz/www-templates

ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["/opt/domoticz/domoticz"]
18 changes: 10 additions & 8 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
#!/bin/bash

TEMPLATE="/opt/domoticz"
USERDATA="${TEMPLATE}/userdata"
SCRIPTS="${USERDATA}/scripts"
WEBROOT="${TEMPLATE}/www"

CMD_ARGS="-www $WWW_PORT"
CMD_ARGS="$CMD_ARGS -noupdates -sslwww $SSL_PORT -userdata /opt/domoticz/userdata"
CMD_ARGS="$CMD_ARGS -noupdates -sslwww $SSL_PORT -userdata ${USERDATA}"

if [ -n "$LOG_PATH" ]; then
CMD_ARGS="$CMD_ARGS -log $LOG_PATH"
Expand All @@ -16,27 +21,24 @@ if [ -n "$EXTRA_CMD_ARG" ]; then
fi

echo "$(date "+%F %T.%3N") Launch: Begin container self-repair"
TEMPLATE="/opt/domoticz"
USERDATA="${TEMPLATE}/userdata"
SCRIPTS="${USERDATA}/scripts"
rsync -airp --ignore-existing --mkpath "${TEMPLATE}/plugins/examples" "${USERDATA}/plugins"
rsync -airp --ignore-existing "${TEMPLATE}/customstart.sh" "${USERDATA}"
rsync -airp --ignore-existing --mkpath "${TEMPLATE}/www/templates" "${USERDATA}/www"
rsync -airp --mkpath "${TEMPLATE}/www-templates/" "${WEBROOT}/templates"
rsync -airp --ignore-existing --mkpath "${TEMPLATE}/scripts/dzVents/examples" "${SCRIPTS}/dzVents"
chown -R 1000:1000 "${USERDATA}"
echo "$(date "+%F %T.%3N") Launch: End container self-repair"

# presence of this file implies the container is already configured
FIRSTRUN="/opt/domoticz/FIRSTRUN"
FIRSTRUN="${TEMPLATE}/FIRSTRUN"

# perform additional configuration if required
if [ ! -f "$FIRSTRUN" ] ; then

echo "$(date "+%F %T.%3N") Launch: Running customstart.sh"
source /opt/domoticz/userdata/customstart.sh
source ${USERDATA}/customstart.sh

# ensure working directory not changed by customstart script
cd /opt/domoticz
cd ${TEMPLATE}

fi

Expand Down