Debian Codegraph @

docker/generic/Dockerfile

raw
1 FROM alpine:3.23
2
3 LABEL maintainer="Roger Light <[email protected]>" \
4 description="Eclipse Mosquitto MQTT Broker"
5
6 ARG VERSION
7 RUN test -n "${VERSION}"
8
9 ENV \
10 GPG_KEYS=A0D6EEA1DCAE49A635A3B2F0779B22DFB3E717B7 \
11 LWS_VERSION=4.2.1 \
12 LWS_SHA256=842da21f73ccba2be59e680de10a8cce7928313048750eb6ad73b6fa50763c51 \
13 CJSON_VERSION=1.7.14 \
14 CJSON_SHA256=fb50a663eefdc76bafa80c82bc045af13b1363e8f45cec8b442007aef6a41343
15
16 LABEL \
17 org.opencontainers.image.authors="Roger Light <[email protected]>" \
18 org.opencontainers.image.title="eclipse-mosquitto" \
19 org.opencontainers.image.description="Eclipse Mosquitto MQTT Broker" \
20 org.opencontainers.image.url="https://mosquitto.org/" \
21 org.opencontainers.image.documentation="https://mosquitto.org/documentation/" \
22 org.opencontainers.image.source="https://github.com/eclipse-mosquitto/mosquitto" \
23 org.opencontainers.image.licenses="EPL-2.0 OR BSD-3-Clause" \
24 org.opencontainers.image.version=${VERSION}
25
26 RUN set -x && \
27 apk --no-cache add --virtual build-deps \
28 build-base \
29 cmake \
30 gnupg \
31 linux-headers \
32 openssl-dev \
33 util-linux-dev && \
34 wget https://github.com/warmcat/libwebsockets/archive/v${LWS_VERSION}.tar.gz -O /tmp/lws.tar.gz && \
35 echo "$LWS_SHA256 /tmp/lws.tar.gz" | sha256sum -c - && \
36 mkdir -p /build/lws && \
37 tar --strip=1 -xf /tmp/lws.tar.gz -C /build/lws && \
38 rm /tmp/lws.tar.gz && \
39 cd /build/lws && \
40 cmake . \
41 -DCMAKE_BUILD_TYPE=MinSizeRel \
42 -DCMAKE_INSTALL_PREFIX=/usr \
43 -DDISABLE_WERROR=ON \
44 -DLWS_IPV6=ON \
45 -DLWS_WITHOUT_BUILTIN_GETIFADDRS=ON \
46 -DLWS_WITHOUT_CLIENT=ON \
47 -DLWS_WITHOUT_EXTENSIONS=ON \
48 -DLWS_WITHOUT_TESTAPPS=ON \
49 -DLWS_WITH_EXTERNAL_POLL=ON \
50 -DLWS_WITH_HTTP2=OFF \
51 -DLWS_WITH_SHARED=OFF \
52 -DLWS_WITH_ZIP_FOPS=OFF \
53 -DLWS_WITH_ZLIB=OFF && \
54 make -j "$(nproc)" && \
55 rm -rf /root/.cmake && \
56 wget https://github.com/DaveGamble/cJSON/archive/v${CJSON_VERSION}.tar.gz -O /tmp/cjson.tar.gz && \
57 echo "$CJSON_SHA256 /tmp/cjson.tar.gz" | sha256sum -c - && \
58 mkdir -p /build/cjson && \
59 tar --strip=1 -xf /tmp/cjson.tar.gz -C /build/cjson && \
60 rm /tmp/cjson.tar.gz && \
61 cd /build/cjson && \
62 cmake . \
63 -DCMAKE_BUILD_TYPE=MinSizeRel \
64 -DBUILD_SHARED_AND_STATIC_LIBS=OFF \
65 -DBUILD_SHARED_LIBS=OFF \
66 -DCJSON_BUILD_SHARED_LIBS=OFF \
67 -DCJSON_OVERRIDE_BUILD_SHARED_LIBS=OFF \
68 -DCMAKE_INSTALL_PREFIX=/usr && \
69 make -j "$(nproc)" && \
70 rm -rf /root/.cmake && \
71 wget https://mosquitto.org/files/source/mosquitto-${VERSION}.tar.gz -O /tmp/mosq.tar.gz && \
72 wget https://mosquitto.org/files/source/mosquitto-${VERSION}.tar.gz.asc -O /tmp/mosq.tar.gz.asc && \
73 export GNUPGHOME="$(mktemp -d)" && \
74 found=''; \
75 for server in \
76 hkps://keys.openpgp.org \
77 hkp://keyserver.ubuntu.com:80 \
78 pgp.mit.edu \
79 ; do \
80 echo "Fetching GPG key $GPG_KEYS from $server"; \
81 gpg --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$GPG_KEYS" && found=yes && break; \
82 done; \
83 test -z "$found" && echo >&2 "error: failed to fetch GPG key $GPG_KEYS" && exit 1; \
84 gpg --batch --verify /tmp/mosq.tar.gz.asc /tmp/mosq.tar.gz && \
85 gpgconf --kill all && \
86 rm -rf "$GNUPGHOME" /tmp/mosq.tar.gz.asc && \
87 mkdir -p /build/mosq && \
88 tar --strip=1 -xf /tmp/mosq.tar.gz -C /build/mosq && \
89 rm /tmp/mosq.tar.gz && \
90 make -C /build/mosq -j "$(nproc)" \
91 CFLAGS="-Wall -O2 -I/build/lws/include -I/build" \
92 LDFLAGS="-L/build/lws/lib -L/build/cjson" \
93 WITH_ADNS=no \
94 WITH_DOCS=no \
95 WITH_SHARED_LIBRARIES=yes \
96 WITH_SRV=no \
97 WITH_STRIP=yes \
98 WITH_TLS_PSK=no \
99 WITH_WEBSOCKETS=yes \
100 prefix=/usr \
101 binary && \
102 addgroup -S -g 1883 mosquitto 2>/dev/null && \
103 adduser -S -u 1883 -D -H -h /var/empty -s /sbin/nologin -G mosquitto -g mosquitto mosquitto 2>/dev/null && \
104 mkdir -p /mosquitto/config /mosquitto/data /mosquitto/log && \
105 install -d /usr/sbin/ && \
106 install -s -m755 /build/mosq/client/mosquitto_pub /usr/bin/mosquitto_pub && \
107 install -s -m755 /build/mosq/client/mosquitto_rr /usr/bin/mosquitto_rr && \
108 install -s -m755 /build/mosq/client/mosquitto_sub /usr/bin/mosquitto_sub && \
109 install -s -m644 /build/mosq/lib/libmosquitto.so.1 /usr/lib/libmosquitto.so.1 && \
110 install -s -m755 /build/mosq/src/mosquitto /usr/sbin/mosquitto && \
111 install -s -m755 /build/mosq/apps/mosquitto_ctrl/mosquitto_ctrl /usr/bin/mosquitto_ctrl && \
112 install -s -m755 /build/mosq/apps/mosquitto_passwd/mosquitto_passwd /usr/bin/mosquitto_passwd && \
113 install -s -m755 /build/mosq/plugins/dynamic-security/mosquitto_dynamic_security.so /usr/lib/mosquitto_dynamic_security.so && \
114 install -m644 /build/mosq/mosquitto.conf /mosquitto/config/mosquitto.conf && \
115 install -Dm644 /build/cjson/LICENSE /usr/share/licenses/cJSON/LICENSE && \
116 install -Dm644 /build/lws/LICENSE /usr/share/licenses/libwebsockets/LICENSE && \
117 install -Dm644 /build/mosq/epl-v20 /usr/share/licenses/mosquitto/epl-v20 && \
118 install -Dm644 /build/mosq/edl-v10 /usr/share/licenses/mosquitto/edl-v10 && \
119 chown -R mosquitto:mosquitto /mosquitto && \
120 apk --no-cache add \
121 ca-certificates \
122 tzdata && \
123 apk del build-deps && \
124 rm -rf /build
125
126 VOLUME ["/mosquitto/data", "/mosquitto/log"]
127
128 # Set up the entry point script and default command
129 COPY docker-entrypoint.sh mosquitto-no-auth.conf /
130 EXPOSE 1883
131 ENTRYPOINT ["/docker-entrypoint.sh"]
132 CMD ["/usr/sbin/mosquitto", "-c", "/mosquitto/config/mosquitto.conf"]