| 1 |
FROM alpine:3.23 |
| 2 |
|
| 3 |
ENV VERSION=2.0.22 \ |
| 4 |
DOWNLOAD_SHA256=2f752589ef7db40260b633fbdb536e9a04b446a315138d64a7ff3c14e2de6b68 \ |
| 5 |
GPG_KEYS=A0D6EEA1DCAE49A635A3B2F0779B22DFB3E717B7 |
| 6 |
|
| 7 |
LABEL \ |
| 8 |
org.opencontainers.image.authors="Roger Light <[email protected]>" \ |
| 9 |
org.opencontainers.image.title="eclipse-mosquitto" \ |
| 10 |
org.opencontainers.image.description="Eclipse Mosquitto MQTT Broker" \ |
| 11 |
org.opencontainers.image.url="https://mosquitto.org/" \ |
| 12 |
org.opencontainers.image.documentation="https://mosquitto.org/documentation/" \ |
| 13 |
org.opencontainers.image.source="https://github.com/eclipse-mosquitto/mosquitto" \ |
| 14 |
org.opencontainers.image.licenses="EPL-2.0 OR BSD-3-Clause" \ |
| 15 |
org.opencontainers.image.version=${VERSION} |
| 16 |
|
| 17 |
RUN set -x && \ |
| 18 |
apk --no-cache add --virtual build-deps \ |
| 19 |
build-base \ |
| 20 |
cmake \ |
| 21 |
cjson-dev \ |
| 22 |
gnupg \ |
| 23 |
libwebsockets-dev \ |
| 24 |
linux-headers \ |
| 25 |
openssl-dev \ |
| 26 |
util-linux-dev && \ |
| 27 |
wget https://mosquitto.org/files/source/mosquitto-${VERSION}.tar.gz -O /tmp/mosq.tar.gz && \ |
| 28 |
echo "$DOWNLOAD_SHA256 /tmp/mosq.tar.gz" | sha256sum -c - && \ |
| 29 |
wget https://mosquitto.org/files/source/mosquitto-${VERSION}.tar.gz.asc -O /tmp/mosq.tar.gz.asc && \ |
| 30 |
export GNUPGHOME="$(mktemp -d)" && \ |
| 31 |
found=''; \ |
| 32 |
for server in \ |
| 33 |
hkps://keys.openpgp.org \ |
| 34 |
hkp://keyserver.ubuntu.com:80 \ |
| 35 |
pgp.mit.edu \ |
| 36 |
; do \ |
| 37 |
echo "Fetching GPG key $GPG_KEYS from $server"; \ |
| 38 |
gpg --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$GPG_KEYS" && found=yes && break; \ |
| 39 |
done; \ |
| 40 |
test -z "$found" && echo >&2 "error: failed to fetch GPG key $GPG_KEYS" && exit 1; \ |
| 41 |
gpg --batch --verify /tmp/mosq.tar.gz.asc /tmp/mosq.tar.gz && \ |
| 42 |
gpgconf --kill all && \ |
| 43 |
rm -rf "$GNUPGHOME" /tmp/mosq.tar.gz.asc && \ |
| 44 |
mkdir -p /build/mosq && \ |
| 45 |
tar --strip=1 -xf /tmp/mosq.tar.gz -C /build/mosq && \ |
| 46 |
rm /tmp/mosq.tar.gz && \ |
| 47 |
make -C /build/mosq -j "$(nproc)" \ |
| 48 |
CFLAGS="-Wall -O2 -I/build" \ |
| 49 |
WITH_ADNS=no \ |
| 50 |
WITH_DOCS=no \ |
| 51 |
WITH_SHARED_LIBRARIES=yes \ |
| 52 |
WITH_SRV=no \ |
| 53 |
WITH_STRIP=yes \ |
| 54 |
WITH_WEBSOCKETS=yes \ |
| 55 |
prefix=/usr \ |
| 56 |
binary && \ |
| 57 |
addgroup -S -g 1883 mosquitto 2>/dev/null && \ |
| 58 |
adduser -S -u 1883 -D -H -h /var/empty -s /sbin/nologin -G mosquitto -g mosquitto mosquitto 2>/dev/null && \ |
| 59 |
mkdir -p /mosquitto/config /mosquitto/data /mosquitto/log && \ |
| 60 |
install -d /usr/sbin/ && \ |
| 61 |
install -s -m755 /build/mosq/client/mosquitto_pub /usr/bin/mosquitto_pub && \ |
| 62 |
install -s -m755 /build/mosq/client/mosquitto_rr /usr/bin/mosquitto_rr && \ |
| 63 |
install -s -m755 /build/mosq/client/mosquitto_sub /usr/bin/mosquitto_sub && \ |
| 64 |
install -s -m644 /build/mosq/lib/libmosquitto.so.1 /usr/lib/libmosquitto.so.1 && \ |
| 65 |
install -s -m755 /build/mosq/src/mosquitto /usr/sbin/mosquitto && \ |
| 66 |
install -s -m755 /build/mosq/apps/mosquitto_ctrl/mosquitto_ctrl /usr/bin/mosquitto_ctrl && \ |
| 67 |
install -s -m755 /build/mosq/apps/mosquitto_passwd/mosquitto_passwd /usr/bin/mosquitto_passwd && \ |
| 68 |
install -s -m755 /build/mosq/plugins/dynamic-security/mosquitto_dynamic_security.so /usr/lib/mosquitto_dynamic_security.so && \ |
| 69 |
install -m644 /build/mosq/mosquitto.conf /mosquitto/config/mosquitto.conf && \ |
| 70 |
install -Dm644 /build/mosq/epl-v20 /usr/share/licenses/mosquitto/epl-v20 && \ |
| 71 |
install -Dm644 /build/mosq/edl-v10 /usr/share/licenses/mosquitto/edl-v10 && \ |
| 72 |
chown -R mosquitto:mosquitto /mosquitto && \ |
| 73 |
apk --no-cache add \ |
| 74 |
ca-certificates \ |
| 75 |
cjson \ |
| 76 |
libwebsockets \ |
| 77 |
tzdata && \ |
| 78 |
apk del build-deps && \ |
| 79 |
rm -rf /build |
| 80 |
|
| 81 |
VOLUME ["/mosquitto/data", "/mosquitto/log"] |
| 82 |
|
| 83 |
# Set up the entry point script and default command |
| 84 |
COPY docker-entrypoint.sh mosquitto-no-auth.conf / |
| 85 |
EXPOSE 1883 |
| 86 |
ENTRYPOINT ["/docker-entrypoint.sh"] |
| 87 |
CMD ["/usr/sbin/mosquitto", "-c", "/mosquitto/config/mosquitto.conf"] |