ualex73/dsmr-reader-docker

By ualex73

Updated 7 months ago

DSMR-Reader Docker Image

Image
5

1M+

ualex73/dsmr-reader-docker repository overview

DSMR-Reader

This image allow to run a instance of DSMR-Reader https://github.com/dennissiemensma/dsmr-reader).

The Docker image is available for the following architectures:

  • amd64 - For regulair Intel/AMD systems (default)
  • arm32v6 - For Raspberry Pi 1/2/Zero
  • arm32v7 - For Raspberry Pi 2/Zero 2
  • arm64v8 - For Raspberry Pi 3 and up

This was initially a fork of xirixiz, because that image wasn't updated regularly enough and didn't had multi architecture support for Raspberry Pi 1/2/3/4/Zero. It also supports the remote datalogger with the same image.

The Docker image is automatically build when Dennis releases a new version.

Raspberry Pi

The Raspberry Pi is based Alpine, but in Alpine 3.13 they introduced a breaking change in the date of the container (it was changed from 32-bit to 64-bit). To allow the Raspberry Pi image to run successfully, you must upgrade the "libseccomp2" to a version 2.4.2 or higher. Only this is not default available in the stable Raspbian repository, so that it not easy. It is available in the back ports and can be installed with the following commands:

$ sudo su -
# apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 04EE7237B7D453EC 648ACFD622F3D138
# echo 'deb http://httpredir.debian.org/debian buster-backports main contrib non-free' | tee -a /etc/apt/sources.list.d/debian-backports.list
# apt update
# apt install libseccomp2 -t buster-backports  

Ports exposed

  • 80 : WebGUI

NOTE: If HTTPS is required, please use Traefik or another proxy to enable this. This makes upgrades easier, because the standard DSMR-Reader configuration isn't changed.

Volumes (optional)

/home/dsmr/app/backups

Devices

/dev/ttyUSB0 - Example of the serial device where the P1 is connected too

Environment Variables (optional)

DSMR_MODE - Run DSMR in 1 of the following modes (default is SERVER):

  • SERVER - Run all processes, including backend, GUI and datalogger
  • SERVER-NO-DATALOGGER - Run server mode without the data logger process. A remote datalogger is required to collect DSMR telegrams
  • DATALOGGER - Only start the datalogger client, which sends the P1 telegrams to the server. It is required to setup DATALOGGER_* environment variables

All environment variables are documented in: https://dsmr-reader.readthedocs.io/nl/v4/reference/env-settings.html

Datalogger configuration:

DSMRREADER_DATALOGGER_API_HOSTS - Destination DSMR Reader host(s), separated by comma. Required if datalogger used.

DSMRREADER_DATALOGGER_API_KEYS - DSMR Reader API key(s), separated by comma. Required if datalogger used.

DSMRREADER_DATALOGGER_INPUT_METHOD - Connection method. Serial or ipv4 (default is serial).

DSMRREADER_DATALOGGER_SERIAL_PORT - Serial port name (default is /dev/ttyUSB0). Only used when input method is serial.

DSMRREADER_DATALOGGER_SERIAL_BAUDRATE - Serial port speed (default is 115200). Only used when input method is serial.

DSMRREADER_DATALOGGER_NETWORK_HOST - Network host (default is localhost). Only used when input method is ipv4.

DSMRREADER_DATALOGGER_NETWORK_PORT - Network host (default is 2000). Only used when input method is ipv4.

More information about the datalogger can be found in the following link: https://dsmr-reader.readthedocs.io/nl/v4/installation/datalogger.html

Docker Run

The following is the run command to start the image, but this is without the postgresql server. It is expected to run on "192.168.1.1" in this example.

docker run -d \
  --name dsmr \
  --restart unless-stopped \
  -p 8888:80 \
  -e DJANGO_DATABASE_HOST=192.168.1.1 \
  -e DSMRREADER_ADMIN_USER=admin \
  -e DSMRREADER_ADMIN_PASSWORD=admin \
  -v /dev:/dev \
  --device /dev/ttyUSB0:/dev/ttyUSB0 \
  ualex73/dsmr-reader-docker

docker-compose.yaml Example

version: '3'
services:
  db-dsmr:
    image: postgres
    container_name: db-dsmr
    volumes:
      - <dir>/db:/var/lib/postgresql/data
    restart: unless-stopped
    environment:
      - POSTGRES_USER=dsmrreader
      - POSTGRES_PASSWORD=dsmrreader
      - POSTGRES_DB=dsmrreader
    networks:
      - net-dsmr

  dsmr:
    container_name: dsmr
    image: ualex73/dsmr-reader-docker
    container_name: dsmr
    restart: unless-stopped
    volumes:
      - ./dsmr/backups:/home/dsmr/app/backups
      - /dev:/dev
    environment:
      - DJANGO_DATABASE_HOST=db-dsmr
      - DSMRREADER_ADMIN_USER=admin
      - DSMRREADER_ADMIN_PASSWORD=password
    ports:
      - 8888:80
    devices:
      - /dev/ttyUSB0:/dev/ttyUSB0
    networks:
      - net-dsmr

networks:
  net-dsmr:
    driver: bridge

To bring up the container with docker compose, use the following command:

docker-compose -f docker-compose.yaml up -d db-dsmr
docker-compose -f docker-compose.yaml up -d dsmr

PostgreSQL Database

"db-dsmr" 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.

Backup the PostgreSQL database to a SQL file:

  1. Stop the DSMR-Reader container:
docker-compose stop dsmr
  1. Make the PostgreSQL export:
docker exec -t db-dsmr pg_dumpall -c -U dsmrreader >postgresql-dump.sql
  1. Start the DSMR-Reader container again:
docker-compose start dsmr

Restore the database from a SQL file:

  1. Stop the DSMR-Reader container:
docker-compose stop dsmr
  1. Drop the existing database, if exists:
docker exec -t db-dsmr dropdb dsmrreader -U dsmrreader
  1. Create the database in PostgreSQL:
docker exec -t db-dsmr createdb -O dsmrreader dsmrreader -U dsmrreader
  1. Import the SQL data into the database:
cat postgresql-dump.sql | docker exec -i db-dsmr psql -U dsmrreader
  1. Start the DSMR-Reader container again:
docker-compose start dsmr

Tag summary

Content type

Image

Digest

sha256:1c567464f

Size

82.3 MB

Last updated

7 months ago

docker pull ualex73/dsmr-reader-docker:5.12.0