-
Notifications
You must be signed in to change notification settings - Fork 124
/
Dockerfile
81 lines (65 loc) · 1.65 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
############################
# STEP 1 build executable binary
############################
FROM alpine:latest AS builder
RUN apk add --no-cache \
gcc \
g++ \
libc-dev \
linux-headers \
git \
make \
cmake \
curl-dev \
gnutls-dev \
cyrus-sasl-dev \
# for libuuid
util-linux-dev \
libtool \
libgcrypt-dev \
libmicrohttpd-dev \
json-c-dev \
mosquitto-dev \
libunistring-dev \
automake \
autoconf \
gtest-dev
WORKDIR /vzlogger
RUN git clone https://github.com/volkszaehler/libsml.git --depth 1 \
&& make install -C libsml/sml
RUN git clone https://github.com/rscada/libmbus.git --depth 1 \
&& cd libmbus \
&& ./build.sh \
&& make install
COPY . /vzlogger
ARG build_test=off
RUN cmake -DBUILD_TEST=${build_test} \
&& make -j $(nproc --all || echo 1) \
&& make install \
&& if [ "$build_test" != "off" ]; then make test; fi
#############################
## STEP 2 build a small image
#############################
FROM alpine:latest
LABEL Description="vzlogger"
RUN apk add --no-cache \
libcurl \
gnutls \
libsasl \
libuuid \
libgcrypt \
libmicrohttpd \
json-c \
libatomic \
mosquitto-libs \
libunistring \
libstdc++ \
libgcc
# libsml is linked statically => no need to copy
COPY --from=builder /usr/local/bin/vzlogger /usr/local/bin/vzlogger
COPY --from=builder /usr/local/lib/libmbus.so* /usr/local/lib/
# without running a user context, no exec is possible and without the dialout group no access to usb ir reader possible
RUN adduser -S vz -G dialout
RUN vzlogger --version
USER vz
CMD ["vzlogger", "--foreground"]