forked from jochocki/rtl2hass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
114 lines (91 loc) · 2.31 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
ARG BUILD_FROM
FROM ${BUILD_FROM} AS intermediate
ARG BUILD_ARCH
ENV LANG C.UTF-8
WORKDIR /usr/share/rtl_433
#
# First install software packages needed to compile RTL-SDR and rtl_433
#
RUN \
apk add --no-cache --virtual \
build_deps \
build-base \
cmake \
git \
libusb-dev
## Pull in rtl-sdr
RUN \
mkdir /tmp/src \
&& cd /tmp/src \
&& git clone git://git.osmocom.org/rtl-sdr.git \
&& mkdir /tmp/src/rtl-sdr/build \
&& cd /tmp/src/rtl-sdr/build \
&& cmake ../ -DINSTALL_UDEV_RULES=ON -DDETACH_KERNEL_DRIVER=ON -DCMAKE_INSTALL_PREFIX:PATH=/usr/local \
&& make \
&& make install \
&& chmod +s /usr/local/bin/rtl_*
#
# Pull RTL_433 source code from GIT, compile it and install it
#
RUN \
git clone https://github.com/merbanan/rtl_433.git . \
&& mkdir build \
&& cd build \
&& cmake ../ \
&& make \
&& make install
## Multi-stage Build
FROM ${BUILD_FROM} AS final
RUN \
apk add --nocache --virtual \
libtool \
libusb-dev \
mosquitto-clients \
jq\
librtlsdr-dev \
rtl-sdr
#
# Define environment variables
#
# Use this variable when creating a container to specify the MQTT broker host.
ENV MQTT_HOST ""
ENV MQTT_PORT 1883
ENV MQTT_USERNAME ""
ENV MQTT_PASSWORD ""
ENV MQTT_TOPIC rtl_433
ENV DISCOVERY_PREFIX homeassistant
ENV DISCOVERY_INTERVAL 600
# RUN \
# apt-get update
# RUN \
# apt-get install --no-install-recommends -y \
# libtool \
# libusb-dev \
# librtlsdr-dev \
# rtl-sdr
COPY --from=intermediate /usr/local/include/rtl_433.h /usr/local/include/rtl_433.h
COPY --from=intermediate /usr/local/include/rtl_433_devices.h /usr/local/include/rtl_433_devices.h
COPY --from=intermediate /usr/local/bin/rtl_433 /usr/local/bin/rtl_433
COPY --from=intermediate /usr/local/etc/rtl_433 /usr/local/etc/rtl_433
#
# Install Paho-MQTT client
#
RUN \
pip3 install --no-cache-dir -U setuptools wheel
RUN \
pip3 install --no-cache-dir --prefer-binary \
--find-links "https://wheels.home-assistant.io/alpine-3.11/${BUILD_ARCH}/" \
paho-mqtt
#
# Blacklist kernel modules for RTL devices
#
COPY rtl.blacklist.conf /etc/modprobe.d/rtl.blacklist.conf
#
# Copy scripts, make executable
#
COPY entry.sh rtl_433_mqtt_hass.py /scripts/
RUN chmod +x /scripts/entry.sh
#
# Execute entry script
#
ENTRYPOINT [ "/scripts/entry.sh" ]