dashticz and docker

Dashticz, alternative dashboard based on HTML, CSS, jQuery

Moderators: leecollings, htilburgs, robgeerts

Post Reply
pvklink
Posts: 822
Joined: Wednesday 12 November 2014 15:01
Target OS: Raspberry Pi / ODroid
Domoticz version: latest b
Contact:

dashticz and docker

Post by pvklink »

I like to install my rpi/domotica environment as much as possible with docker.
Is it possible to include the install of dashticz, apache/php or ngninx fully by docker compose and a dockerfile ?
i tried to make a start with the 2 files (abd more dockerfiles for the rest)
( i already have the latest domoticz, mqtt and node-red working by docker)

Code: Select all

version: '3.6'
services:
  domoticz:
    container_name: domoticz
    build: ./services/domoticz/.
    #image: domoticz/domoticz:latest
    ports:
    - "82:8080"
    - "6144:6144"
    - "1443:1443"
    - "9000:9000"
    devices:
    - '/dev/ttyUSB0:/dev/ttyUSB0'
    volumes:
    - ./volumes/domoticz/data:/opt/domoticz/userdata
    restart: unless-stopped
    network_mode: bridge
    environment:
    - PUID=1000
    - PGID=1000
    #- LOG_PATH=/opt/domoticz/userdata/domoticz.log
  dashticz:
    container_name: dashticz
    build: ./services/dashticz/.
    ports:
    - "90:90"
    volumes:
    - ./volumes/dashticz:/opt/????
    restart: unless-stopped
    network_mode: bridge
  mosquitto:
    container_name: mosquitto
    image: eclipse-mosquitto
    restart: unless-stopped
    user: "1000"
    ports:
    - "1883:1883"
    volumes:
    - ./volumes/mosquitto/data:/mosquitto/data
    - ./volumes/mosquitto/log:/mosquitto/log
    - ./volumes/mosquitto/pwfile:/mosquitto/pwfile
    - ./volumes/mosquitto:/mosquitto/config:ro
    network_mode: bridge
  nodered:
    container_name: nodered
    build: ./services/nodered/.
    restart: unless-stopped
    user: "0"
    privileged: true
    environment:
      - TZ=Etc/UTC
    ports:
      - "1880:1880"
    volumes:
      - "./volumes/nodered/data:/data"
      - "/var/run/docker.sock:/var/run/docker.sock"
      - "/var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket"
    devices:
      - "/dev/gpiomem:/dev/gpiomem"
      - "/dev/ttyAMA0:/dev/ttyAMA0"
      - "/dev/vcio:/dev/vcio"
    networks:
      - iotstack_nw
    logging:
      options:
        max-size: 5m
        max-file: "3"
networks:
  iotstack_nw:
    name: IOTstack_Net
    # external: true
    driver: bridge
    ipam:
      driver: default
      config:
        - subnet: 10.77.60.0/24

Code: Select all

# Dockerfile for Dashticz
FROM nginx
USER root

RUN apt-get update
RUN apt-get install -y nginx --no-install-recommends

RUN apt-get install git

# Remove the default Nginx configuration file
RUN rm -v /etc/nginx/nginx.conf

# Copy a configuration file from the current directory
COPY nginx.conf /etc/nginx/

RUN rm -rf /usr/share/nginx/html/

# Append "daemon off;" to the beginning of the configuration
RUN echo "daemon off;" >> /etc/nginx/nginx.conf

# Expose ports
EXPOSE 90

# Set the default command to execute
# when creating a new container
CMD service nginx start

Last edited by pvklink on Saturday 10 April 2021 15:29, edited 1 time in total.
Raspberry (raspbian on rpi 3) , Domoticz Beta, dzVents , RFXtrx433e, P1, Hue, Yeelight, Zwave+, X10, ESP(easy), MQTT,Weather Underground, System Alive Checker, Domoticz Remote Server to RPI with Google Assistant,
Jablotron connection, Ikea
Lokonli
Posts: 2262
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: dashticz and docker

Post by Lokonli »

That should be possible.

Dashticz makes use of PHP in the webserver, so you should include that into your image.
And you need to mount a writable folder custom/ for the config files (CONFIG.js, custom.css, custom.js).

That should be sufficient.

Maybe a parameter for selecting beta or master.

The auto-install script also makes use of a Dockerimage, but in fact only for the php-webserver functionality. Dashticz itself is installed via git clone on the host directly. That makes updating Dashticz a bit easier.
pvklink
Posts: 822
Joined: Wednesday 12 November 2014 15:01
Target OS: Raspberry Pi / ODroid
Domoticz version: latest b
Contact:

Re: dashticz and docker

Post by pvklink »

Indeed, the auto-install script is great for installing dashticz (webserver/php).
But i started a way to install all my component as a docker via one compose file and dockerfiles per application...
Was inspired by IOTstack (beta)... :-)
i already have the casco in place (compose an dockerfile and volumes , one for dashticz...
Now figuring out the right content for the composefile and the dashtic/apache/php file.
Think i need a formal apache/php image file as a start via a dockerfile and add dashticz to it..

I could need some help, so if someone has parts of code for me, that would be appreciated. :-)
Only played for two weeks with docker and stil strugling which software/packets has to be installed
Raspberry (raspbian on rpi 3) , Domoticz Beta, dzVents , RFXtrx433e, P1, Hue, Yeelight, Zwave+, X10, ESP(easy), MQTT,Weather Underground, System Alive Checker, Domoticz Remote Server to RPI with Google Assistant,
Jablotron connection, Ikea
Lokonli
Posts: 2262
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: dashticz and docker

Post by Lokonli »

Did some experiments myself.

Create the following docker file, named 'dashticz.docker':

Code: Select all

FROM php:7.4-apache
ARG tz="Europe/Amsterdam" 
RUN printf "[PHP]\ndate.timezone = $tz\n" > /usr/local/etc/php/conf.d/tzone.ini && \
mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
RUN apt update && apt install git -y
RUN echo "if [ ! -f /var/www/html/version.txt ]; then git clone --depth 1 --branch beta  https://github.com/Dashticz/dashticz /var/www/html; chmod -R a+rw /var/www/html/custom; chmod -R a+rw /var/www/html/img;fi; apache2-foreground" > /usr/bin/init.sh && chmod +x /usr/bin/init.sh 
CMD ["/usr/bin/init.sh"]
SHELL ["/bin/bash", "-c"]
and the following docker-compose.yaml:

Code: Select all

version: "3.5"
services:
  dashticz:
    build:
      context: .   
      dockerfile: dashticz.docker
    container_name: "dt38"
    ports:
      - "8200:80"
    restart: always
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - type: bind
        source: ./dashticz/
        target: /var/www/html/
Create a folder 'dashticz'.

Build and start the Dashticz container:

Code: Select all

sudo docker-compose up
create your CONFIG.js in ./dashticz/custom/CONFIG.js

This way you still can hack the Dashticz sources in the dashticz tree, if needed.

I've hardly any docker experience, so I guess the scripts can be improved. Suggestions are more than welcome :)
pvklink
Posts: 822
Joined: Wednesday 12 November 2014 15:01
Target OS: Raspberry Pi / ODroid
Domoticz version: latest b
Contact:

Re: dashticz and docker

Post by pvklink »

Cool ! gonna test it!

I am busy with passwords with mqtt docker container and that part succeeded!

I will post all my stuff how to install a domotica environment with docker (after installing a default OS+ docker) when i got everything working.
i got domoticz, hue, zwave, rfxcom, dzvents mqtt en nodered 99% ready.All the config files and data are outside the containers and one click to update them all!

Last part is broadlink (ready, no errors but not working, is lot of python install shit in dockerfile)
and.. your setup, gonna try !!! cant wait...
Raspberry (raspbian on rpi 3) , Domoticz Beta, dzVents , RFXtrx433e, P1, Hue, Yeelight, Zwave+, X10, ESP(easy), MQTT,Weather Underground, System Alive Checker, Domoticz Remote Server to RPI with Google Assistant,
Jablotron connection, Ikea
pvklink
Posts: 822
Joined: Wednesday 12 November 2014 15:01
Target OS: Raspberry Pi / ODroid
Domoticz version: latest b
Contact:

Re: dashticz and docker

Post by pvklink »

Ok, i included your code in my configs, so i had to adjust a little bit..
Good news :-) and bad news..
a. Compose batch for all packets/apps went without errors, and all dockers started!
b. Dashticz volumes files were created...

When i start dashticz with: http://192.168.20.38/dashticz/index.html i got a no found...

When ik look at IOTstack log option i see: 192.168.1.10 (is my pc), but after GET and before /dashticz there is no IP !

dashticz | 192.168.1.10 - - [11/Apr/2021:20:35:25 +0200] "GET /dashticz/index.html HTTP/1.1" 404 492 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:87.0) Gecko/20100101 Firefox/87.0"

my compose file

Code: Select all

version: '3.6'
services:
  domoticz:
    container_name: domoticz
    build: ./services/domoticz/.
    #image: domoticz/domoticz:latest
    ports:
    - "82:8080"
    - "6144:6144"
    - "1443:1443"
    - "9000:9000"
    devices:
    - '/dev/ttyUSB0:/dev/ttyUSB0'
    volumes:
    - ./volumes/domoticz/data:/opt/domoticz/userdata
    restart: unless-stopped
    network_mode: bridge
    environment:
    - PUID=1000
    - PGID=1000
    #- LOG_PATH=/opt/domoticz/userdata/domoticz.log
  dashticz:
    container_name: dashticz
    build: ./services/dashticz/.
    #context: .   
    restart: always
    ports:
      - "80:80"
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - type: bind
        source: ./volumes/dashticz/
        target: /var/www/html/
  motion:
    container_name: motion
    image: motionproject/motion:latest
    #build: ./services/motion/.
    ports:
   # camera and streamports
    - "7999:7999"
    - "8081:8081"
    - "8082:8082"
    - "8083:8083"
    - "8084:8084"
    - "8085:8085"
    - "8087:8087"
    volumes:
      - "./volumes/motion/config:/usr/local/etc/motion"
      - "./volumes/motion/storage:/var/lib/motion"
    restart: unless-stopped
    environment:
      - TZ=Etc/UTC
    networks:
      - iotstack_nw
  mosquitto:
    container_name: mosquitto
    image: eclipse-mosquitto
    restart: unless-stopped
    user: "1000"
    ports:
    - "1883:1883"
    volumes:
    - ./volumes/mosquitto/data:/mosquitto/data
    - ./volumes/mosquitto/log:/mosquitto/log
    - ./volumes/mosquitto/pwfile:/mosquitto/pwfile
    - ./volumes/mosquitto/config:/mosquitto/config:ro
    network_mode: bridge
  nodered:
    container_name: nodered
    build: ./services/nodered/.
    restart: unless-stopped
    user: "0"
    privileged: true
    environment:
      - TZ=Etc/UTC
    ports:
      - "1880:1880"
    volumes:
      - "./volumes/nodered/data:/data"
      - "/var/run/docker.sock:/var/run/docker.sock"
      - "/var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket"
    devices:
      - "/dev/gpiomem:/dev/gpiomem"
      - "/dev/ttyAMA0:/dev/ttyAMA0"
      - "/dev/vcio:/dev/vcio"
    networks:
      - iotstack_nw
    logging:
      options:
        max-size: 5m
        max-file: "3"
networks:
  iotstack_nw:
    name: IOTstack_Net
    # external: true
    driver: bridge
    ipam:
      driver: default
      config:
        - subnet: 10.77.60.0/24
my Dockerfile

Code: Select all

FROM php:7.4-apache
ARG tz="Europe/Amsterdam" 
RUN printf "[PHP]\ndate.timezone = $tz\n" > /usr/local/etc/php/conf.d/tzone.ini && \
mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
RUN apt update && apt install git -y
RUN echo "if [ ! -f /var/www/html/version.txt ]; then git clone --depth 1 --branch beta  https://github.com/Dashticz/dashticz /var/www/html; chmod -R a+rw /var/www/html/custom; chmod -R a+rw /var/www/html/img;fi; apache2-foreground" > /usr/bin/init.sh && chmod +x /usr/bin/init.sh 
CMD ["/usr/bin/init.sh"]
SHELL ["/bin/bash", "-c"]

Raspberry (raspbian on rpi 3) , Domoticz Beta, dzVents , RFXtrx433e, P1, Hue, Yeelight, Zwave+, X10, ESP(easy), MQTT,Weather Underground, System Alive Checker, Domoticz Remote Server to RPI with Google Assistant,
Jablotron connection, Ikea
Lokonli
Posts: 2262
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: dashticz and docker

Post by Lokonli »

pvklink
Posts: 822
Joined: Wednesday 12 November 2014 15:01
Target OS: Raspberry Pi / ODroid
Domoticz version: latest b
Contact:

Re: dashticz and docker

Post by pvklink »

:-)

Another part working on Docker!
you are great!

Tomorrow trying to get the last two
motion
and
a pain in the ass: broadlink
Raspberry (raspbian on rpi 3) , Domoticz Beta, dzVents , RFXtrx433e, P1, Hue, Yeelight, Zwave+, X10, ESP(easy), MQTT,Weather Underground, System Alive Checker, Domoticz Remote Server to RPI with Google Assistant,
Jablotron connection, Ikea
Lokonli
Posts: 2262
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: dashticz and docker

Post by Lokonli »

Did you look at motioneye already instead of motion?

Verstuurd vanaf mijn AC2003 met Tapatalk

pvklink
Posts: 822
Joined: Wednesday 12 November 2014 15:01
Target OS: Raspberry Pi / ODroid
Domoticz version: latest b
Contact:

Re: dashticz and docker

Post by pvklink »

:-) was another idea on the backlist...

But if motioneye also can (just like motion)
- record data from videostreams
- activate a http string when motion is enable (enable a domoticz device with that)

Then i start with motion-eye
Raspberry (raspbian on rpi 3) , Domoticz Beta, dzVents , RFXtrx433e, P1, Hue, Yeelight, Zwave+, X10, ESP(easy), MQTT,Weather Underground, System Alive Checker, Domoticz Remote Server to RPI with Google Assistant,
Jablotron connection, Ikea
Lokonli
Posts: 2262
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: dashticz and docker

Post by Lokonli »

yes. And it has a nice web interface.
pvklink
Posts: 822
Joined: Wednesday 12 November 2014 15:01
Target OS: Raspberry Pi / ODroid
Domoticz version: latest b
Contact:

Re: dashticz and docker

Post by pvklink »

ok, you got me...:-)

And how do you see the integration with dashticz ?
My current situation:

- Motion: grab video, storage on nas
- Dashticz show flows from cams
Raspberry (raspbian on rpi 3) , Domoticz Beta, dzVents , RFXtrx433e, P1, Hue, Yeelight, Zwave+, X10, ESP(easy), MQTT,Weather Underground, System Alive Checker, Domoticz Remote Server to RPI with Google Assistant,
Jablotron connection, Ikea
Lokonli
Posts: 2262
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: dashticz and docker

Post by Lokonli »

Install motion-eye with docker-compose:

Code: Select all

version: "3.5"
services:
  motioneye:
    image: ccrisan/motioneye:master-amd64  # Change to ccrisan/motioneye:master-armhf for ARM chips (Pi etc.)
    ports:
      - "8901:8081"
      - "8765:8765"
    restart: always
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - ./etc_motioneye:/etc/motioneye
      - ./var_lib_motioneye:/var/lib/motioneye
For each camera you have to forward an additional port, starting at 8081.
At port 8765 the motioneye web interface will run.
You may have to create the two motioneye volumes in the current folder first.

You will have three links per camera.
(One for snapshot, one for MJPEG, one for embedded frame)
motioneye.jpg
motioneye.jpg (40.47 KiB) Viewed 1123 times
You have to use the url with the ports that are valid for the host, not for the container. So, with my port mapping, that will become something like:
Snapshot: http://my-ip:8765/picture/1/current/
mjpeg: http://my-ip:8901

You can use the snapshot url in a Dashticz button. (and the mjpeg stream as well).
Both will work within the camera block as well.

To trigger on motion, create a virtual switch in Domoticz.
Enable motion notification in MotionEye:
webhook.jpg
webhook.jpg (30.37 KiB) Viewed 1123 times
As webhook url use:

Code: Select all

http://domoticz-ip:8080/json.htm?type=command&param=switchlight&idx=1099&switchcmd=On
You have to whitelist the MotionEye IP-address within Domoticz. MotionEye is running in a Docker container. I had to whitelist the following IP range:
172.26.*.*

in domoticz you can see the camera as well. Configure the Domoticz camera as follows:
domoticz cam.jpg
domoticz cam.jpg (44.82 KiB) Viewed 1123 times
(replace host-ip with the correct host ip, without http, without port number)
pvklink
Posts: 822
Joined: Wednesday 12 November 2014 15:01
Target OS: Raspberry Pi / ODroid
Domoticz version: latest b
Contact:

Re: dashticz and docker

Post by pvklink »

Got motion also working in docker,

So now the
- motion-eye and
- broadlink

I tried motion-eye myself, but worked once and after that i could not add cams
Gonna try your setup...
Raspberry (raspbian on rpi 3) , Domoticz Beta, dzVents , RFXtrx433e, P1, Hue, Yeelight, Zwave+, X10, ESP(easy), MQTT,Weather Underground, System Alive Checker, Domoticz Remote Server to RPI with Google Assistant,
Jablotron connection, Ikea
pvklink
Posts: 822
Joined: Wednesday 12 November 2014 15:01
Target OS: Raspberry Pi / ODroid
Domoticz version: latest b
Contact:

Re: dashticz and docker

Post by pvklink »

Your motioneye docker version, works! :-) :-) :-)
Manual is great, got two cams working
Gonna play with it to integrate it in dashticz, with motion and dashticz i had to enter the username and password, i think that solved too now with motioneye...:-)

Another thing to check is how to stop the motioneye recording when a certain switch in domoticz is on or off. (example off from home, security on)
Option is to stop the motioneye docker entirely..

i have 6 apps ready ! and all data and configs outside docker on one share, easy to recover
(you did also a large and nasty part! THANKS for that @lokonli)

Last one is the most difficult, because it installs without error, but does not work... the broadlink plugin in domoticz!
I did a post for this in another part of the forum.. but i think broadlink and docker is not used much...
Raspberry (raspbian on rpi 3) , Domoticz Beta, dzVents , RFXtrx433e, P1, Hue, Yeelight, Zwave+, X10, ESP(easy), MQTT,Weather Underground, System Alive Checker, Domoticz Remote Server to RPI with Google Assistant,
Jablotron connection, Ikea
pvklink
Posts: 822
Joined: Wednesday 12 November 2014 15:01
Target OS: Raspberry Pi / ODroid
Domoticz version: latest b
Contact:

Re: dashticz and docker

Post by pvklink »

@lokonli

in case you are also playing with docker:
I have 90% working with one compose file and some of them have a dockerfile

all separate dockers with external storage and some of them can communicate with each other
- mysql
- mosquitto
- phpmyadmin
- domoticz
- dashticz
- motioneye
- motion
- nodered

so with one click install (after copied the datatree with all configparams en databases)

To do:
- plugin broadlink (ready but not working)
Raspberry (raspbian on rpi 3) , Domoticz Beta, dzVents , RFXtrx433e, P1, Hue, Yeelight, Zwave+, X10, ESP(easy), MQTT,Weather Underground, System Alive Checker, Domoticz Remote Server to RPI with Google Assistant,
Jablotron connection, Ikea
pvklink
Posts: 822
Joined: Wednesday 12 November 2014 15:01
Target OS: Raspberry Pi / ODroid
Domoticz version: latest b
Contact:

Re: dashticz and docker

Post by pvklink »

Hi, I have my cams now in motioneye (via a docker) as you advised, and that works great!
I tried to integrate these two cams in dashticz , but i have to scroll to see the second cam that is presented below the first cam...
Is there a way to show them both in one (part off a) screen and when clicking , only the one that is selected?

blocks["webcams"] =
{
type: "camera",
cameras:[
{title: "Tuinview",imageUrl: "http://192.168.20.32:8901",},
{title: "Straatview",imageUrl: "http://192.168.20.32:8902",},
],
width: 12,
height: 500,
refresh: 3,
traytimeout: 3,
slidedelay: 3,
forcerefresh: 1,
};

columns['video']= {blocks: ['webcams'], width: 10}

screens['tablet'] = {maxwidth: 1024,maxheight: 768}
screens['tablet'][1] = {background: 'bg1.jpg', columns: ['home1','home2']}
screens['tablet'][2] = {background: 'bg1.jpg', columns: ['sec1','sec2']}
screens['tablet'][3] = {background: 'bg1.jpg', columns: ['media1','media2']}
screens['tablet'][4] = {background: 'bg1.jpg', columns: ['irrigatie']}
screens['tablet'][5] = {background: 'bg1.jpg', columns: ['sensor1','sensor2']}
screens['tablet'][6] = {background: 'bg1.jpg', columns: ['video']}
Raspberry (raspbian on rpi 3) , Domoticz Beta, dzVents , RFXtrx433e, P1, Hue, Yeelight, Zwave+, X10, ESP(easy), MQTT,Weather Underground, System Alive Checker, Domoticz Remote Server to RPI with Google Assistant,
Jablotron connection, Ikea
ArnovP
Posts: 3
Joined: Monday 07 January 2019 21:04
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: Netherlands
Contact:

Re: dashticz and docker

Post by ArnovP »

pvklink wrote: Monday 12 April 2021 21:47

Another thing to check is how to stop the motioneye recording when a certain switch in domoticz is on or off. (example off from home, security on)
Option is to stop the motioneye docker entirely..

Do you have a solution for this? I don't work with Docker, I have MotionEyeOS and Domoticz on 2 seperate Raspberries....

edit:

I found something myself: https://github.com/ccrisan/motioneyeos/issues/1778
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest