Giter Club home page Giter Club logo

dsmr-reader-docker's Introduction

DockerPulls BuyMeCoffee

DSMR Reader - Environment variables

Now it's possible to set the following settings as environment variables, for example:

Required (defaults are shown as value):
- TZ=Europe/Amsterdam
- VIRTUAL_HOST=localhost
Optional (defaults are shown as value):

Supervisord related:
- SD_LOGLEVEL=info
- SD_USER=root
- SD_GROUP=root
- SD_AUTOSTART_DATALOGGER=true
- SD_AUTORESTART_DATALOGGER=true
- SD_AUTOSTART_BACKEND=true
- SD_AUTORESTART_BACKEND=true
- SD_AUTOSTART_MQTT=true
- SD_AUTORESTART_MQTT=true

DSMR related (defaults are shown as value):
- DSMR_USER=admin
- DSMR_EMAIL=root@localhost
- DSMR_PASSWORD=admin
- DSMR_BACKEND_SLEEP=<value in seconds>
- DSMR_DATALOGGER_SLEEP=<value in seconds>

DB related (defaults are shown as value):
- DB_HOST=dsmrdb
- DB_PORT=5432
- DB_USER=dsmrreader
- DB_PASS=dsmrreader
- DB_NAME dsmrreader

DSMR Reader - Docker

A docker-compose file in order to start the following application in Docker: dsmr-reader (https://github.com/dennissiemensma/dsmr-reader)

ualex73 created a fork, but that's based on an old setup. Docker image sizes have been reduced drastically (old 380mb, new 70mb), both for dsmr and dsmrdb.

The following architectures are available on the Docker Hub:

  • amd64 (default)
  • arm32
  • arm64

See https://hub.docker.com/r/xirixiz/dsmr-reader-docker/tags/ for the available images. You can create specific architecture files by running the update_hub_images.sh file. Dockerfile.cross is being used as input (template).

You should first add the user you run Docker with on your host file system to the dialout group:

sudo usermod -aG dialout $(whoami)

Docker-compose

An example docker-compose.yaml file can be found here: https://raw.githubusercontent.com/xirixiz/dsmr-reader-docker/master/docker-compose.example.yaml

You should modify the docker-compose file with parameters that suit your environment, then run docker-compose afterwards:

docker-compose up -d

After starting the containers with docker-compose, the dashboard is reachable at HTTP: http://<hostname>:7777

After starting the containers, don't forget to modify the default DSMR version (default is DSMR v4): http://<hostname>:7777/admin/dsmr_datalogger/dataloggersettings/

Docker run

Keep in mind the example below only runs dsmr, you need to run a postgres docker container or traditional postgres environment as well, since a database is needed.

docker run -d \
  --name dsmr \
  --restart always \
  -p 7777:80 \
  -p 7779:443 \
  -e TZ=Europe/Amsterdam \
  -e DB_HOST=x.x.x.x \
  -e DB_USER=dsmrreader \
  -e DB_PASS=dsmrreader \
  -e VIRTUAL_HOST=localhost \
  --device /dev/ttyUSB0:/dev/ttyUSB0 \
  xirixiz/dsmr-reader-docker

Backup and restore meganism 1

dsmrdb in docker-compose is configured to use a docker volume. So when the application and docker containter have been removed, the postgres data still persists.

Also you could easily create a backup. Values depend on docker/docker-compose user and database variables:

docker-compose stop dsmr
docker exec -t dsmrdb pg_dumpall -c -U dsmrreader > dsmrreader.sql
docker-compose start dsmr

Or drop the database and restore a backup. Values depend on docker/docker-compose user and database variables:

docker-compose stop dsmr
docker exec -t dsmrdb dropdb dsmrreader -U dsmrreader
docker exec -t dsmrdb createdb -O dsmrreader dsmrreader -U dsmrreader
cat dsmrreader.sql | docker exec -i dsmrdb psql -U dsmrreader
docker-compose start dsmr

Backup and restore meganism 2

Ofcourse it's also possible to use Docker's own volume backup and restore megansim.

Backup:

docker run -it --rm -v dsmrdb:/volume -v /tmp:/backup alpine \
    tar -cjf /backup/dsmrdb.tar.bz2 -C /volume ./

Restore:

docker run -it --rm -v dsmrdb:/volume -v /tmp:/backup alpine \
    sh -c "rm -rf /volume/* /volume/..?* /volume/.[!.]* ; tar -C /volume/ -xjf /backup/dsmrdb.tar.bz2"

Important notes

The current configuration has been tested on Ubuntu > 17.x and Manjaro > 17.x

For Synology users:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.