Commit a734b82fdeb06317540b0ef4f52541a990868f96

Authored by Maurits van der Vijgh
Committed by Wiebe Cazemier
1 parent 0b1af555

Add dockerfile and build/run instructions

.dockerignore 0 → 100644
  1 +Dockerfile
Dockerfile 0 → 100644
  1 +# build target, used for building the binary, providing shared libraries and could be used as a development env
  2 +FROM debian:bullseye-slim as build
  3 +
  4 +# install build dependencies
  5 +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install g++ make cmake libssl-dev
  6 +
  7 +# create flashmq user and group for runtime image below
  8 +RUN useradd --system --shell /bin/false --user-group --no-log-init flashmq
  9 +
  10 +WORKDIR /usr/src/app
  11 +COPY . .
  12 +RUN ./build.sh
  13 +
  14 +
  15 +# from scratch image is empty
  16 +FROM scratch as run
  17 +
  18 +# set the user/group to flashmq and copy the passwd/group files from build to make that work
  19 +USER flashmq:flashmq
  20 +COPY --from=build /etc/passwd /etc/passwd
  21 +COPY --from=build /etc/group /etc/group
  22 +
  23 +# copy in the shared libaries in use discovered using ldd on release binary
  24 +COPY --from=build /lib/x86_64-linux-gnu/libpthread.so.0 /lib/x86_64-linux-gnu/libpthread.so.0
  25 +COPY --from=build /lib/x86_64-linux-gnu/libdl.so.2 /lib/x86_64-linux-gnu/libdl.so.2
  26 +COPY --from=build /usr/lib/x86_64-linux-gnu/libssl.so.1.1 /usr/lib/x86_64-linux-gnu/libssl.so.1.1
  27 +COPY --from=build /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1
  28 +COPY --from=build /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /usr/lib/x86_64-linux-gnu/libstdc++.so.6
  29 +COPY --from=build /lib/x86_64-linux-gnu/libgcc_s.so.1 /lib/x86_64-linux-gnu/libgcc_s.so.1
  30 +COPY --from=build /lib/x86_64-linux-gnu/libc.so.6 /lib/x86_64-linux-gnu/libc.so.6
  31 +COPY --from=build /lib64/ld-linux-x86-64.so.2 /lib64/ld-linux-x86-64.so.2
  32 +COPY --from=build /lib/x86_64-linux-gnu/libm.so.6 /lib/x86_64-linux-gnu/libm.so.6
  33 +
  34 +# copy in the FlashMQ binary itself
  35 +COPY --from=build /usr/src/app/FlashMQBuildRelease/FlashMQ /bin/FlashMQ
  36 +
  37 +EXPOSE 1883
  38 +CMD ["/bin/FlashMQ"]
README.md
@@ -5,4 +5,21 @@ FlashMQ is a light-weight MQTT broker/server, designed to take good advantage of @@ -5,4 +5,21 @@ FlashMQ is a light-weight MQTT broker/server, designed to take good advantage of
5 5
6 Build with buid.sh. 6 Build with buid.sh.
7 7
  8 +## Docker
  9 +
  10 +Official Docker images aren't available yet, but building your own Docker image can be done with the provided Dockerfile.
  11 +
  12 +```
  13 +# build flashmq docker image
  14 +docker build . -t halfgaar/flashmq
  15 +
  16 +# run using docker (with, as an example, a place for a config file (default
  17 +# name flashmq.conf). Create extra volumes as you need, for the persistence DB
  18 +# file, logs, password files, auth plugin, etc.
  19 +docker run -p 1883:1883 -v /srv/flashmq/etc/:/etc/flashmq halfgaar/flashmq
  20 +
  21 +# for development you can target the build stage to get an image you can use for development
  22 +docker build . --target=build
  23 +```
  24 +
8 See [www.flashmq.org](https://www.flashmq.org) 25 See [www.flashmq.org](https://www.flashmq.org)