From 0da2b507b4c7fccb34c2a5eeda30705cef54192a Mon Sep 17 00:00:00 2001 From: ludeeus Date: Sun, 24 Mar 2019 16:56:34 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20Build=20libwesocket=20and=20mosq?= =?UTF-8?q?uitto=20from=20source?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mqtt/Dockerfile | 66 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 59 insertions(+), 7 deletions(-) diff --git a/mqtt/Dockerfile b/mqtt/Dockerfile index 0f5e911..3e5f990 100644 --- a/mqtt/Dockerfile +++ b/mqtt/Dockerfile @@ -11,21 +11,73 @@ WORKDIR /app # Copy root filesystem COPY rootfs / +# Versions +ENV HIVEMQ='46338a633eb26bc9f6d8d8ff82f8f2aedc004a57' \ + LIBWEBSOCKETS='2.4.2' \ + MOSQUITTO='1.5.8' + # Setup base RUN \ - apk add --no-cache \ + apk add --no-cache --virtual .build-dependencies \ + git=2.20.1-r0 \ + cmake=3.13.0-r0 \ + build-base=0.5-r1 \ + zlib-dev=1.2.11-r1 \ + openssl-dev=1.1.1b-r1 \ + \ + && apk add --no-cache \ nginx=1.14.2-r0 \ lua-resty-http=0.12-r1 \ nginx-mod-http-lua=1.14.2-r0 \ - mosquitto=1.5.6-r0 \ \ - && curl -J -L -o /tmp/web.zip \ - "https://github.com/hivemq/hivemq-mqtt-web-client/archive/46338a633eb26bc9f6d8d8ff82f8f2aedc004a57.zip" \ + && git clone --depth=1 \ + https://github.com/hivemq/hivemq-mqtt-web-client.git /app \ + && cd /app \ + && git checkout "${HIVEMQ}" \ + \ + && git clone --branch "v${LIBWEBSOCKETS}" --depth=1 \ + https://github.com/warmcat/libwebsockets.git /tmp/libwebsockets \ + \ + && mkdir -p /tmp/libwebsockets/build \ + && cd /tmp/libwebsockets/build \ + && cmake .. \ + -DCMAKE_BUILD_TYPE=MinSizeRel \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DLWS_IPV6=OFF \ + -DLWS_WITHOUT_BUILTIN_GETIFADDRS=ON \ + -DLWS_WITHOUT_CLIENT=ON \ + -DLWS_WITHOUT_EXTENSIONS=ON \ + -DLWS_WITHOUT_TESTAPPS=ON \ + -DLWS_WITH_SHARED=OFF \ + -DLWS_WITH_ZIP_FOPS=OFF \ + -DLWS_WITH_ZLIB=OFF \ + && make \ + && make install \ + \ + && git clone --branch "v${MOSQUITTO}" --depth=1 \ + https://github.com/eclipse/mosquitto.git /tmp/mosquitto \ + \ + && cd /tmp/mosquitto \ + && make \ + WITH_ADNS=no \ + WITH_DOCS=no \ + WITH_UUID=no \ + WITH_MEMORY_TRACKING=no \ + WITH_SHARED_LIBRARIES=no \ + WITH_SRV=no \ + WITH_STRIP=yes \ + WITH_TLS_PSK=no \ + WITH_WEBSOCKETS=yes \ + prefix=/usr \ + binary \ + && make WITH_DOCS=no install binary \ \ - && unzip -d /tmp /tmp/web.zip \ - && mv /tmp/hivemq-mqtt-web-client-*/* /app \ + && addgroup -S mosquitto \ + && adduser -S -D -H -h /var/empty -s /sbin/nologin \ + -G mosquitto -g mosquitto mosquitto \ \ - && rm -fr /tmp/* + && rm -fr /tmp/* \ + && apk del --no-cache --purge .build-dependencies # Build arguments ARG BUILD_ARCH