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
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM python:3.14-slim-bookworm

RUN mkdir /app
COPY smartmeter_datacollector/ /app/smartmeter_datacollector/
COPY pyproject.toml /app
COPY README.md /app

WORKDIR /app
ENV PYTHONPATH=${PYTHONPATH}:${PWD}

RUN pip3 install poetry
RUN poetry config virtualenvs.create false
RUN poetry install

CMD ["poetry", "run", "smartmeter-datacollector" ]
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,43 @@ The configuration file can be located anywhere and use any filename. If no `.ini

When `smartmeter-datacollector` has been installed as a Debian package it provides a systemd .service file named `smartmeter-datacollector.service`. Therefore the service can be managed using the `systemctl` command. See [Run as a systemd service](https://github.com/scs/smartmeter-datacollector/wiki/How-to-use#run-as-a-systemd-service) for possible commands.

## Run as a Docker image with docker compose

`smartmeter-datacollector` can be run with docker compose and a docker image, built from sources.

- Provide a valid .ini configuration file (see example below)
- in a newly created `.env` file set:
- `SMARTMETER_DATACOLLECTOR_INI`: this file gets mounted into the docker container and is used by the service
- `SMARTMETER_SERIAL_DEVICE`: the serial connection to the smartmeter
4. Run `docker compose up`

### Example files

#### `.env`

```
DATACOLLECTOR_INI=./datacollector.ini
SERIAL_DEVICE=/dev/serial/by-id/device
```

#### `datacollector.ini`

```
[reader0]
type = kamstrup_han
port = /dev/ttyUSB0
key = supersecretHexKey

[sink0]
type = mqtt
host = mqtt.localdomain
port = 1883
tls = False
ca_file_path =
check_hostname = False
username =
password =
```

# How to develop

Expand Down
9 changes: 9 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
services:
smartmeter:
build: .
container_name: smartmeter
restart: unless-stopped
devices:
- ${SMARTMETER_SERIAL_DEVICE}:/dev/ttyUSB0
volumes:
- ${SMARTMETER_DATACOLLECTOR_INI}:/app/datacollector.ini:rw