91 lines
4.0 KiB
Docker
91 lines
4.0 KiB
Docker
|
|
# Define Mosquitto version, see also .github/workflows/build_and_push_docker_images.yml for
|
|
# the automatically built images
|
|
ARG MOSQUITTO_VERSION=1.6.14
|
|
# Define libwebsocket version
|
|
ARG LWS_VERSION=4.2.2
|
|
|
|
# Use debian:stable-slim as a builder for Mosquitto and dependencies.
|
|
FROM debian:stable-slim as mosquitto_builder
|
|
ARG MOSQUITTO_VERSION
|
|
ARG LWS_VERSION
|
|
|
|
ENV GO_VERSION=1.18
|
|
# Used in run-test-in-docker.sh to check if the script
|
|
# is actually run in a container
|
|
ENV MOSQUITTO_GO_AUTH_TEST_RUNNING_IN_A_CONTAINER=true
|
|
|
|
WORKDIR /app
|
|
|
|
#Get mosquitto build dependencies.
|
|
RUN apt-get update && apt-get install -y libc-ares2 libc-ares-dev cmake libssl-dev uuid uuid-dev wget build-essential git libcjson-dev gnupg lsb-release
|
|
|
|
# Get libwebsocket. Debian's libwebsockets is too old for Mosquitto version > 2.x so it gets built from source.
|
|
RUN set -ex; \
|
|
wget 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; \
|
|
rm /tmp/lws.tar.gz; \
|
|
cd /build/lws; \
|
|
cmake . \
|
|
-DCMAKE_BUILD_TYPE=MinSizeRel \
|
|
-DCMAKE_INSTALL_PREFIX=/usr \
|
|
-DLWS_IPV6=ON \
|
|
-DLWS_WITHOUT_BUILTIN_GETIFADDRS=ON \
|
|
-DLWS_WITHOUT_CLIENT=ON \
|
|
-DLWS_WITHOUT_EXTENSIONS=ON \
|
|
-DLWS_WITHOUT_TESTAPPS=ON \
|
|
-DLWS_WITH_HTTP2=OFF \
|
|
-DLWS_WITH_SHARED=OFF \
|
|
-DLWS_WITH_ZIP_FOPS=OFF \
|
|
-DLWS_WITH_ZLIB=OFF \
|
|
-DLWS_WITH_EXTERNAL_POLL=ON; \
|
|
make -j "$(nproc)"; \
|
|
rm -rf /root/.cmake
|
|
|
|
RUN mkdir -p mosquitto/auth mosquitto/conf.d
|
|
|
|
RUN wget http://mosquitto.org/files/source/mosquitto-${MOSQUITTO_VERSION}.tar.gz
|
|
RUN tar xzvf mosquitto-${MOSQUITTO_VERSION}.tar.gz && rm mosquitto-${MOSQUITTO_VERSION}.tar.gz
|
|
|
|
# Build mosquitto.
|
|
RUN set -ex; \
|
|
cd mosquitto-${MOSQUITTO_VERSION}; \
|
|
make CFLAGS="-Wall -O2 -I/build/lws/include" LDFLAGS="-L/build/lws/lib" WITH_WEBSOCKETS=yes; \
|
|
make install; \
|
|
cd ..;
|
|
|
|
#Get Go.
|
|
RUN wget https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz && tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz
|
|
RUN export PATH=$PATH:/usr/local/go/bin && go version && rm go${GO_VERSION}.linux-amd64.tar.gz
|
|
|
|
#Build the plugin from local source
|
|
COPY ./ ./
|
|
|
|
#Build the plugin.
|
|
RUN export PATH=$PATH:/usr/local/go/bin && export CGO_CFLAGS="-I/usr/local/include -fPIC" && export CGO_LDFLAGS="-shared" && make
|
|
|
|
## Everything above, is the same as Dockerfile
|
|
|
|
RUN apt-get update && apt-get install --no-install-recommends -y mariadb-server postgresql sudo
|
|
|
|
RUN wget -qO - https://www.mongodb.org/static/pgp/server-7.0.asc | gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg --dearmor && \
|
|
echo "deb [signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg] https://repo.mongodb.org/apt/debian $(lsb_release -cs)/mongodb-org/7.0 main" | tee /etc/apt/sources.list.d/mongodb-org-7.0.list && \
|
|
apt-get update && \
|
|
# starting with MongoDB 7.0, the postinst for server includes "systemctl daemon-reload" (and we don't have "systemctl")
|
|
ln -s /bin/true /usr/bin/systemctl && \
|
|
apt-get install -y mongodb-org && \
|
|
rm -f /usr/bin/systemctl
|
|
|
|
#Install redis 6.2
|
|
RUN wget -qO - https://packages.redis.io/gpg | gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg && \
|
|
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/redis.list && \
|
|
apt-get update && \
|
|
apt-get install -y redis-tools=6:6.2.* redis-server=6:6.2.*
|
|
|
|
# Install CFSSL to generate test certificates required for tests
|
|
RUN export PATH=$PATH:/usr/local/go/bin && go install github.com/cloudflare/cfssl/cmd/cfssl@v1.6.2 && cp ~/go/bin/cfssl /usr/local/bin
|
|
RUN export PATH=$PATH:/usr/local/go/bin && go install github.com/cloudflare/cfssl/cmd/cfssljson@v1.6.2 && cp ~/go/bin/cfssljson /usr/local/bin
|
|
|
|
# Pre-compilation of test for speed-up latest re-run
|
|
RUN export PATH=$PATH:/usr/local/go/bin && go test -c ./backends -o /dev/null |