forked from robertsLando/Zwave2Mqtt-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
95 lines (78 loc) · 2.28 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
# ----------------
# STEP 1:
# https://lobradov.github.io/Building-docker-multiarch-images/
# Build Openzwave and Zwave2Mqtt pkg
# All result files will be put in /dist folder
FROM node:carbon-alpine AS build
# Set the commit of Zwave2Mqtt to checkout when cloning the repo
ENV Z2M_VERSION=30c1ba879d4468d30d08f7beacce45ec29af1a02
# Install required dependencies
RUN apk update && apk --no-cache add \
gnutls \
gnutls-dev \
libusb \
eudev \
# Install build dependencies
&& apk --no-cache --virtual .build-deps add \
coreutils \
eudev-dev \
build-base \
git \
python \
bash \
libusb-dev \
linux-headers \
wget \
tar \
openssl \
make
# Build binaries and move them to /dist/lib
RUN cd /root \
&& wget http://old.openzwave.com/downloads/openzwave-1.4.1.tar.gz \
&& tar zxvf openzwave-*.gz \
&& cd openzwave-* && make && make install \
&& mkdir -p /dist/lib \
&& mv libopenzwave.so* /dist/lib/
COPY bin/package.sh /root/package.sh
# Clone Zwave2Mqtt build pkg files and move them to /dist/pkg
RUN npm config set unsafe-perm true && npm install -g [email protected] \
&& cd /root \
&& git clone https://github.com/OpenZWave/Zwave2Mqtt.git \
&& cd Zwave2Mqtt \
&& git checkout ${Z2M_VERSION} \
&& npm install \
&& npm run build
RUN cd /root \
&& chmod +x package.sh && ./package.sh \
&& mkdir -p /dist/pkg \
&& mv /root/Zwave2Mqtt/pkg/* /dist/pkg
# Get last config DB from main repo and move files to /dist/db
RUN cd /root \
&& git clone https://github.com/OpenZWave/open-zwave.git \
&& cd open-zwave \
&& mkdir -p /dist/db \
&& mv config/* /dist/db
# Clean up
RUN rm -R /root/* && apk del .build-deps
# ----------------
# STEP 2:
# Run a minimal alpine image
FROM alpine:latest
LABEL maintainer="robertsLando"
RUN apk update && apk add --no-cache \
libstdc++ \
libgcc \
libusb \
tzdata \
eudev
# Copy files from previous build stage
COPY --from=build /dist/lib/ /lib/
COPY --from=build /dist/db/ /usr/local/etc/openzwave/
COPY --from=build /dist/pkg /usr/src/app
# Set enviroment
ENV LD_LIBRARY_PATH /lib
WORKDIR /usr/src/app
EXPOSE 8091
# Override default alpine entrypoint
ENTRYPOINT [""]
CMD ["/usr/src/app/zwave2mqtt"]