-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbroker.Dockerfile
65 lines (55 loc) · 2.76 KB
/
broker.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
FROM debian:bookworm-slim
LABEL maintainer="Jeff Wang <[email protected]>" \
description="Mosquitto MQTT Custom Edition Broker"
ENV VERSION=2.0.20 \
LWS_VERSION=4.2.1 \
MDM_VERSION=1.1.2
RUN set -x && \
apt update && apt install -y --no-install-recommends locales wget build-essential cmake sudo openssl \
libcjson-dev libssl-dev && \
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'zh_CN.UTF-8 UTF-8' > /etc/locale.gen && /usr/sbin/locale-gen && \
wget --no-check-certificate https://github.com/warmcat/libwebsockets/archive/v${LWS_VERSION}.tar.gz -O /tmp/lws.tar.gz && \
mkdir -p /build/lws && \
tar --strip=1 -xf /tmp/lws.tar.gz -C /build/lws && \
cd /build/lws && \
cmake . \
-DCMAKE_BUILD_TYPE=MinSizeRel \
-DCMAKE_INSTALL_PREFIX=/usr \
-DDISABLE_WERROR=ON \
-DLWS_IPV6=ON \
-DLWS_WITHOUT_BUILTIN_GETIFADDRS=ON \
-DLWS_WITHOUT_CLIENT=ON \
-DLWS_WITHOUT_EXTENSIONS=ON \
-DLWS_WITHOUT_TESTAPPS=ON \
-DLWS_WITH_EXTERNAL_POLL=ON \
-DLWS_WITH_HTTP2=OFF \
-DLWS_WITH_SHARED=OFF \
-DLWS_WITH_ZIP_FOPS=OFF \
-DLWS_WITH_ZLIB=OFF && \
make -j "$(nproc)" && make install && \
wget --no-check-certificate https://mosquitto.org/files/source/mosquitto-${VERSION}.tar.gz -O /tmp/mosq.tar.gz && \
mkdir -p /build/mosq && \
tar --strip=1 -xf /tmp/mosq.tar.gz -C /build/mosq && \
cd /build/mosq && \
sed -i 's|prefix?=/usr/local|prefix?=/usr|g' config.mk && \
sed -i 's|WITH_DOCS:=yes|WITH_DOCS:=no|g' config.mk && \
sed -i 's|WITH_WEBSOCKETS:=no|WITH_WEBSOCKETS:=yes|g' config.mk && \
make -j "$(nproc)" && make install && \
cd apps/db_dump && make && cp mosquitto_db_dump /usr/bin/mosquitto_db_dump && \
wget --no-check-certificate https://github.com/blusewang/mosquitto-delay-message/archive/refs/tags/${MDM_VERSION}.tar.gz -O /tmp/mdm.tar.gz && \
mkdir -p /build/mdm && \
tar --strip=1 -xf /tmp/mdm.tar.gz -C /build/mdm && \
sed -i 's|set(CMAKE_INSTALL_LIBDIR /usr/local/lib)|set(CMAKE_INSTALL_LIBDIR /usr/lib)|g' /build/mdm/CMakeLists.txt && \
cd /build/mdm && \
cmake . && \
make -j "$(nproc)" && make install && \
mkdir /data && \
addgroup --gid 1883 mosquitto && useradd -s /bin/bash -c mosquitto -d /data -g 1883 -G mosquitto -m -u 1883 -p $(echo 'mosquitto' | openssl passwd -1 -stdin) mosquitto && \
echo 'mosquitto ALL=(ALL) ALL' >> /etc/sudoers && \
chown mosquitto:mosquitto /data && \
rm -rf /tmp/* && rm -rf /build && \
apt purge -y wget build-essential cmake wget && apt autoremove -y && rm -rf /var/lib/apt/lists/*
VOLUME /data
USER mosquitto
EXPOSE 1883 1884 1885 1886
CMD ["/usr/sbin/mosquitto", "-c", "/data/mosquitto.conf"]