-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
85 lines (76 loc) · 3.17 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
FROM alpine:3.8
# Build-time metadata as defined at http://label-schema.org
ARG BUILD_DATE
ARG VCS_REF
ARG VERSION
LABEL maintainer="Joan Llopis <[email protected]>" \
org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name="mosquitto MQTT Brocker with auth-plugin" \
org.label-schema.description="This project builds mosquitto with auth-plugin. \
It also has mosquitto_pub, mosquitto_sub and np." \
org.label-schema.url="https://cloud.docker.com/u/jllopis/repository/docker/jllopis/mosquitto" \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url="https://github.com/jllopis/docker-mosquitto" \
org.label-schema.version=$VERSION \
org.label-schema.schema-version="1.0"
EXPOSE 1883
EXPOSE 9883
VOLUME ["/var/lib/mosquitto", "/etc/mosquitto", "/etc/mosquitto.d"]
RUN addgroup -S mosquitto && \
adduser -S -H -h /var/empty -s /sbin/nologin -D -G mosquitto mosquitto
ENV PATH=/usr/local/bin:/usr/local/sbin:$PATH
ENV MOSQUITTO_VERSION=v1.5.5
ENV LIBWEBSOCKETS_VERSION=v3.1-stable
COPY run.sh /
RUN apk --no-cache add --virtual buildDeps git cmake build-base libressl-dev c-ares-dev util-linux-dev hiredis-dev postgresql-dev curl-dev; \
chmod +x /run.sh && \
mkdir -p /var/lib/mosquitto && \
touch /var/lib/mosquitto/.keep && \
mkdir -p /etc/mosquitto.d && \
apk add hiredis postgresql-libs libuuid c-ares libressl curl ca-certificates && \
git clone -b ${LIBWEBSOCKETS_VERSION} https://libwebsockets.org/repo/libwebsockets && \
cd libwebsockets && \
cmake . \
-DCMAKE_BUILD_TYPE=MinSizeRel \
-DLWS_IPV6=ON \
-DLWS_WITHOUT_CLIENT=ON \
-DLWS_WITHOUT_TESTAPPS=ON \
-DLWS_WITHOUT_EXTENSIONS=ON \
-DLWS_WITHOUT_BUILTIN_GETIFADDRS=ON \
-DLWS_WITH_ZIP_FOPS=OFF \
-DLWS_WITH_ZLIB=OFF \
-DLWS_WITH_SHARED=OFF && \
make -j "$(nproc)" && \
rm -rf /root/.cmake && \
make install && \
cd .. && \
git clone -b ${MOSQUITTO_VERSION} https://github.com/eclipse/mosquitto.git && \
cd mosquitto && \
make -j "$(nproc)" \
CFLAGS="-Wall -O2 -I/libwebsockets/include" \
LDFLAGS="-L/libwebsockets/lib" \
WITH_SRV=yes \
WITH_ADNS=no \
WITH_DOCS=no \
WITH_MEMORY_TRACKING=no \
WITH_TLS_PSK=no \
WITH_WEBSOCKETS=yes \
install && \
git clone git://github.com/jpmens/mosquitto-auth-plug.git && \
cd mosquitto-auth-plug && \
cp config.mk.in config.mk && \
sed -i "s/BACKEND_REDIS ?= no/BACKEND_REDIS ?= yes/" config.mk && \
sed -i "s/BACKEND_HTTP ?= no/BACKEND_HTTP ?= yes/" config.mk && \
sed -i "s/BACKEND_MYSQL ?= yes/BACKEND_MYSQL ?= no/" config.mk && \
sed -i "s/BACKEND_POSTGRES ?= no/BACKEND_POSTGRES ?= yes/" config.mk && \
sed -i "s/BACKEND_JWT ?= no/BACKEND_JWT ?= yes/" config.mk && \
sed -i "s/MOSQUITTO_SRC =/MOSQUITTO_SRC = ..\//" config.mk && \
make -j "$(nproc)" && \
install -s -m755 auth-plug.so /usr/local/lib/ && \
install -s -m755 np /usr/local/bin/ && \
cd / && rm -rf mosquitto && \
rm -rf libwebsockets && \
apk del buildDeps && rm -rf /var/cache/apk/*
ADD mosquitto.conf /etc/mosquitto/mosquitto.conf
ENTRYPOINT ["/run.sh"]
CMD ["mosquitto"]