Adding rtl_433 to docker and updating README

Adding rtl_433 to docker container and updating README for RTLSDR dongles
pull/133/head
BIBOLV 2020-07-01 21:00:12 +03:00
rodzic afc48275b3
commit 5e6cad064a
4 zmienionych plików z 42 dodań i 21 usunięć

Wyświetl plik

@ -1,19 +1,22 @@
FROM multiarch/alpine:amd64-latest-stable AS build
RUN apk add --no-cache alpine-sdk gcc linux-headers ncurses-dev
RUN apk add --no-cache alpine-sdk gcc linux-headers ncurses-dev librtlsdr-dev cmake libusb-dev
RUN git clone https://github.com/weetmuts/wmbusmeters.git && \
git clone https://github.com/xaelsouth/rtl-wmbus.git
git clone https://github.com/xaelsouth/rtl-wmbus.git && \
git clone https://github.com/merbanan/rtl_433.git
WORKDIR /wmbusmeters
RUN make
WORKDIR /rtl-wmbus
RUN make release && chmod 755 build/rtl_wmbus
WORKDIR /rtl_433
RUN mkdir build && cd build && cmake ../ && make
FROM multiarch/alpine:amd64-latest-stable as scratch
ENV QEMU_EXECVE=1
RUN apk add --no-cache mosquitto-clients libstdc++ curl libusb ncurses && \
apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/main rtl-sdr
RUN apk add --no-cache mosquitto-clients libstdc++ curl libusb ncurses rtl-sdr
WORKDIR /wmbusmeters
COPY --from=build /wmbusmeters/build/wmbusmeters /wmbusmeters/wmbusmeters
COPY --from=build /rtl-wmbus/build/rtl_wmbus /usr/bin/rtl_wmbus
COPY --from=build /rtl_433/build/src/rtl_433 /usr/bin/rtl_433
COPY docker/docker-entrypoint.sh /wmbusmeters/docker-entrypoint.sh
VOLUME /wmbusmeters_data/
CMD ["sh", "/wmbusmeters/docker-entrypoint.sh"]

Wyświetl plik

@ -1,19 +1,22 @@
FROM multiarch/alpine:arm64-latest-stable AS build
RUN apk add --no-cache alpine-sdk gcc linux-headers ncurses-dev
RUN apk add --no-cache alpine-sdk gcc linux-headers ncurses-dev librtlsdr-dev cmake libusb-dev
RUN git clone https://github.com/weetmuts/wmbusmeters.git && \
git clone https://github.com/xaelsouth/rtl-wmbus.git
git clone https://github.com/xaelsouth/rtl-wmbus.git && \
git clone https://github.com/merbanan/rtl_433.git
WORKDIR /wmbusmeters
RUN make
WORKDIR /rtl-wmbus
RUN make release && chmod 755 build/rtl_wmbus
WORKDIR /rtl_433
RUN mkdir build && cd build && cmake ../ && make
FROM multiarch/alpine:arm64-latest-stable as scratch
ENV QEMU_EXECVE=1
RUN apk add --no-cache mosquitto-clients libstdc++ curl libusb ncurses && \
apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/main rtl-sdr
RUN apk add --no-cache mosquitto-clients libstdc++ curl libusb ncurses rtl-sdr
WORKDIR /wmbusmeters
COPY --from=build /wmbusmeters/build/wmbusmeters /wmbusmeters/wmbusmeters
COPY --from=build /rtl-wmbus/build/rtl_wmbus /usr/bin/rtl_wmbus
COPY --from=build /rtl_433/build/src/rtl_433 /usr/bin/rtl_433
COPY docker/docker-entrypoint.sh /wmbusmeters/docker-entrypoint.sh
VOLUME /wmbusmeters_data/
CMD ["sh", "/wmbusmeters/docker-entrypoint.sh"]

Wyświetl plik

@ -1,19 +1,22 @@
FROM multiarch/alpine:armhf-latest-stable AS build
RUN apk add --no-cache alpine-sdk gcc linux-headers ncurses-dev
RUN apk add --no-cache alpine-sdk gcc linux-headers ncurses-dev librtlsdr-dev cmake libusb-dev
RUN git clone https://github.com/weetmuts/wmbusmeters.git && \
git clone https://github.com/xaelsouth/rtl-wmbus.git
git clone https://github.com/xaelsouth/rtl-wmbus.git && \
git clone https://github.com/merbanan/rtl_433.git
WORKDIR /wmbusmeters
RUN make
WORKDIR /rtl-wmbus
RUN make release && chmod 755 build/rtl_wmbus
WORKDIR /rtl_433
RUN mkdir build && cd build && cmake ../ && make
FROM multiarch/alpine:armhf-latest-stable as scratch
ENV QEMU_EXECVE=1
RUN apk add --no-cache mosquitto-clients libstdc++ curl libusb ncurses && \
apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/main rtl-sdr
RUN apk add --no-cache mosquitto-clients libstdc++ curl libusb ncurses rtl-sdr
WORKDIR /wmbusmeters
COPY --from=build /wmbusmeters/build/wmbusmeters /wmbusmeters/wmbusmeters
COPY --from=build /rtl-wmbus/build/rtl_wmbus /usr/bin/rtl_wmbus
COPY --from=build /rtl_433/build/src/rtl_433 /usr/bin/rtl_433
COPY docker/docker-entrypoint.sh /wmbusmeters/docker-entrypoint.sh
VOLUME /wmbusmeters_data/
CMD ["sh", "/wmbusmeters/docker-entrypoint.sh"]

Wyświetl plik

@ -12,9 +12,9 @@ MQTT, curled to a REST api, inserted into a database or stored in a log file.
- Linux x86-64 (`amd64`)
## Running the wmbusmeters container
### Pre-requisite
### Prerequisite
Before running the command that creates the wmbusmeters docker container, you must add udev rules to create usb device symlink in order to have persistent link to device across host restarts and reconnect usb device:
Before running the command that creates the wmbusmeters docker container, udev rules must be added to create usb device symlink in order to have persistent link to device across host restarts and reconnects of usb device:
```
cat <<EOF > /etc/udev/rules.d/99-wmbus-usb-serial.rules
SUBSYSTEM=="tty", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", SYMLINK+="im871a", MODE="0660", GROUP="docker"
@ -22,9 +22,8 @@ SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", SYMLINK+="a
SUBSYSTEM=="usb", ATTRS{idVendor}=="2047", ATTRS{idProduct}=="0863", SYMLINK+="rfmrx2", MODE="0660", GROUP="docker"
EOF
```
> For RTLSDR symlink passing to docker image is not working due to fact that rtl_ binaries are looking for full usb bus path in system to identify device. Full usb bus path should be passed to docker `--device=/dev/bus/usb/002/117` for example and in wmbusmeters config file `device=auto` should be changed to `device=rtlwmbus`
### Command line container download and run
### Command line for container download and run
```
docker run -d \
@ -42,12 +41,12 @@ docker run -d \
| --name=wmbusmeters | Names the container "wmbusmeters". |
| --restart=always | Start the container when Docker starts (i.e. on boot/reboot). |
| -v /etc/localtime:/etc/localtime:ro | Ensure the container has the correct local time. |
| -v /opt/wmbusmeters:/wmbusmeters_data | Bind mount /opt/wmbusmeters (or the directory of your choice) into the container for persistent storage that will contain configuration and log files. |
| --device=/dev/im871a | Pass the device at ttyUSB0 into the container for use by wmbusmeters (you may need to change path to your device ). |
| -v /opt/wmbusmeters:/wmbusmeters_data | Bind mount /opt/wmbusmeters (or any other directory) into the container for persistent storage that will contain configuration and log files. |
| --device=/dev/im871a | Passes the device at /dev/im871a into the container for use by wmbusmeters (path to device may need to be changed). |
> Specify device in configuration file if wmbusmeters does not find device by changeing `device=auto` to `device=/dev/im871a` for example.
> Device must be specified in configuration file if wmbusmeters does not find device by changing `device=auto` to `device=/dev/im871a` for example.
If you are using docker-compose.yml file you may also copy/paste the following into your existing docker-compose.yml, modifying the options as required (omit the version and services lines as your docker-compose.yml will already contain these).
If docker-compose.yml file is being used, then it is also possible to copy/paste the following into existing docker-compose.yml, modifying the options as required (by omitting the version and services lines as existing docker-compose.yml may already contain those).
```
version: "2"
services:
@ -62,7 +61,20 @@ services:
- /dev/im871a
```
Then, you can do docker-compose pull to pull the latest weetmuts/wmbusmeters image, docker-compose up -d to start the wmbusmeters container service, and docker-compose down to stop the wmbusmeters service and delete the container. Note that these commands will also pull, start, and stop any other services defined in docker-compose.yml.
Then, `docker-compose pull` can be used to pull the latest weetmuts/wmbusmeters image, `docker-compose up -d` to start the wmbusmeters container service, and `docker-compose down` to stop the wmbusmeters service and delete the container. It must be noted that those commands will also pull, start, and stop any other services defined in docker-compose.yml.
### Using RTLSDR dongles with container
For RTLSDR symlink passing to docker image is not working due to the fact that rtl_ binaries are looking for a full usb bus path in the system to identify device. When using RTLSDR following docker command should be used to start container and in wmbusmeters config file `device=auto` should be changed to `device=rtlwmbus`
```
docker run -d --privileged \
--name=wmbusmeters \
--restart=always \
-v /etc/localtime:/etc/localtime:ro \
-v /opt/wmbusmeters:/wmbusmeters_data \
-v /dev/bus/usb/:/dev/bus/usb/ \
weetmuts/wmbusmeters
```
### Issues / Contributing