| 1 |
FROM ubuntu:24.04 |
| 2 |
|
| 3 |
ENV VERSION=2.1.1 \ |
| 4 |
DOWNLOAD_SHA256=d93026a8f8255a32fe146ca77df5e26259b7947745370a3944a68ddb4ec663ff \ |
| 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 |
apt-get update && \ |
| 19 |
apt-get install -y \ |
| 20 |
build-essential \ |
| 21 |
cmake \ |
| 22 |
gnupg \ |
| 23 |
libargon2-dev \ |
| 24 |
libcjson-dev \ |
| 25 |
libedit-dev \ |
| 26 |
libmicrohttpd-dev \ |
| 27 |
libssl-dev \ |
| 28 |
libsqlite3-dev \ |
| 29 |
wget && \ |
| 30 |
wget https://mosquitto.org/files/source/mosquitto-${VERSION}.tar.gz -O /tmp/mosq.tar.gz && \ |
| 31 |
echo "$DOWNLOAD_SHA256 /tmp/mosq.tar.gz" | sha256sum -c - && \ |
| 32 |
wget https://mosquitto.org/files/source/mosquitto-${VERSION}.tar.gz.asc -O /tmp/mosq.tar.gz.asc && \ |
| 33 |
export GNUPGHOME="$(mktemp -d)" && \ |
| 34 |
found=''; \ |
| 35 |
for server in \ |
| 36 |
hkps://keys.openpgp.org \ |
| 37 |
hkp://keyserver.ubuntu.com:80 \ |
| 38 |
pgp.mit.edu \ |
| 39 |
; do \ |
| 40 |
echo "Fetching GPG key $GPG_KEYS from $server"; \ |
| 41 |
gpg --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$GPG_KEYS" && found=yes && break; \ |
| 42 |
done; \ |
| 43 |
test -z "$found" && echo >&2 "error: failed to fetch GPG key $GPG_KEYS" && exit 1; \ |
| 44 |
gpg --batch --verify /tmp/mosq.tar.gz.asc /tmp/mosq.tar.gz && \ |
| 45 |
gpgconf --kill all && \ |
| 46 |
rm -rf "$GNUPGHOME" /tmp/mosq.tar.gz.asc && \ |
| 47 |
mkdir -p /build/mosq && \ |
| 48 |
tar --strip=1 -xf /tmp/mosq.tar.gz -C /build/mosq && \ |
| 49 |
rm /tmp/mosq.tar.gz && \ |
| 50 |
make -C /build/mosq -j "$(nproc)" \ |
| 51 |
CFLAGS="-Wall -O2 -I/build -DHTTP_API_DIR=\\\"/usr/share/mosquitto/dashboard\\\"" \ |
| 52 |
WITH_ADNS=no \ |
| 53 |
WITH_DOCS=no \ |
| 54 |
WITH_SHARED_LIBRARIES=yes \ |
| 55 |
WITH_SRV=no \ |
| 56 |
WITH_STRIP=yes \ |
| 57 |
WITH_WEBSOCKETS=yes \ |
| 58 |
prefix=/usr \ |
| 59 |
binary && \ |
| 60 |
addgroup --system --quiet --gid 1883 mosquitto 2>/dev/null && \ |
| 61 |
adduser --system --quiet --no-create-home --ingroup mosquitto --uid 1883 --home /var/empty --shell /usr/sbin/nologin mosquitto 2>/dev/null && \ |
| 62 |
mkdir -p /mosquitto/config /mosquitto/data /mosquitto/log && \ |
| 63 |
install -d /usr/sbin/ && \ |
| 64 |
install -s -m755 /build/mosq/client/mosquitto_pub /usr/bin/mosquitto_pub && \ |
| 65 |
install -s -m755 /build/mosq/client/mosquitto_rr /usr/bin/mosquitto_rr && \ |
| 66 |
install -s -m755 /build/mosq/client/mosquitto_sub /usr/bin/mosquitto_sub && \ |
| 67 |
install -s -m644 /build/mosq/lib/libmosquitto.so.1 /usr/lib/libmosquitto.so.1 && \ |
| 68 |
install -s -m755 /build/mosq/src/mosquitto /usr/sbin/mosquitto && \ |
| 69 |
install -s -m755 /build/mosq/apps/mosquitto_ctrl/mosquitto_ctrl /usr/bin/mosquitto_ctrl && \ |
| 70 |
install -s -m755 /build/mosq/apps/mosquitto_passwd/mosquitto_passwd /usr/bin/mosquitto_passwd && \ |
| 71 |
install -s -m755 /build/mosq/apps/mosquitto_signal/mosquitto_signal /usr/bin/mosquitto_signal && \ |
| 72 |
install -s -m755 /build/mosq/plugins/acl-file/mosquitto_acl_file.so /usr/lib/mosquitto_acl_file.so && \ |
| 73 |
install -s -m755 /build/mosq/plugins/dynamic-security/mosquitto_dynamic_security.so /usr/lib/mosquitto_dynamic_security.so && \ |
| 74 |
install -s -m755 /build/mosq/plugins/password-file/mosquitto_password_file.so /usr/lib/mosquitto_password_file.so && \ |
| 75 |
install -s -m755 /build/mosq/plugins/persist-sqlite/mosquitto_persist_sqlite.so /usr/lib/mosquitto_persist_sqlite.so && \ |
| 76 |
install -s -m755 /build/mosq/plugins/sparkplug-aware/mosquitto_sparkplug_aware.so /usr/lib/mosquitto_sparkplug_aware.so && \ |
| 77 |
install -m644 /build/mosq/docker/2.1-ubuntu/mosquitto.conf /mosquitto/config/mosquitto.conf && \ |
| 78 |
install -m644 /build/mosq/docker/2.1-ubuntu/mosquitto.conf /mosquitto-no-auth.conf && \ |
| 79 |
install -d /usr/share/mosquitto && \ |
| 80 |
cp -r /build/mosq/dashboard/src /usr/share/mosquitto/dashboard && \ |
| 81 |
install -Dm644 /build/mosq/epl-v20 /usr/share/licenses/mosquitto/epl-v20 && \ |
| 82 |
install -Dm644 /build/mosq/edl-v10 /usr/share/licenses/mosquitto/edl-v10 && \ |
| 83 |
chown -R mosquitto:mosquitto /mosquitto && \ |
| 84 |
apt-get install \ |
| 85 |
ca-certificates \ |
| 86 |
libargon2-1 \ |
| 87 |
libcjson1 \ |
| 88 |
libedit2 \ |
| 89 |
libmicrohttpd12 \ |
| 90 |
libsqlite3-0 && \ |
| 91 |
apt-get clean && \ |
| 92 |
apt-get remove --purge --auto-remove -y build-essential cmake gnupg && \ |
| 93 |
rm -rf /var/lib/apt/lists/* && \ |
| 94 |
rm -rf /build |
| 95 |
|
| 96 |
VOLUME ["/mosquitto/data", "/mosquitto/log"] |
| 97 |
|
| 98 |
# Set up the entry point script and default command |
| 99 |
COPY docker-entrypoint.sh / |
| 100 |
EXPOSE 1883 |
| 101 |
ENTRYPOINT ["/docker-entrypoint.sh"] |
| 102 |
CMD ["/usr/sbin/mosquitto", "-c", "/mosquitto/config/mosquitto.conf"] |