From 3d26f067dead3b848bf46f836cf111808e085931 Mon Sep 17 00:00:00 2001 From: Dirk Alders Date: Fri, 23 Jun 2023 13:16:57 +0200 Subject: [PATCH] mqtt added to configuration --- mqtt/Dockerfile | 15 +++++++++++++++ mqtt/config_templates/open/mosquitto.conf | 10 ++++++++++ .../config_templates/protected/mosquitto.conf | 12 ++++++++++++ mqtt/config_templates/protected/passwd | 0 mqtt/docker-compose.template | 19 +++++++++++++++++++ 5 files changed, 56 insertions(+) create mode 100644 mqtt/Dockerfile create mode 100644 mqtt/config_templates/open/mosquitto.conf create mode 100644 mqtt/config_templates/protected/mosquitto.conf create mode 100644 mqtt/config_templates/protected/passwd create mode 100644 mqtt/docker-compose.template diff --git a/mqtt/Dockerfile b/mqtt/Dockerfile new file mode 100644 index 0000000..9efaa8b --- /dev/null +++ b/mqtt/Dockerfile @@ -0,0 +1,15 @@ +FROM eclipse-mosquitto:2 + +arg UID=1000 +arg GID=1000 +arg USER=unicorn + +RUN if [ ${USER} != "root" ]; then \ + apk add shadow && \ + groupadd -f -g ${GID} ${USER} && \ + useradd -m -g ${USER} -u ${UID} ${USER}; \ + fi + +RUN chown -R ${USER}:${USER} /mosquitto + +USER ${USER} diff --git a/mqtt/config_templates/open/mosquitto.conf b/mqtt/config_templates/open/mosquitto.conf new file mode 100644 index 0000000..e33dd40 --- /dev/null +++ b/mqtt/config_templates/open/mosquitto.conf @@ -0,0 +1,10 @@ +listener 1883 +persistence true +persistence_location /mosquitto/data/ + +## Authentication ## +allow_anonymous true + +## Logging - possibilities: error, warning, notice, information, all +log_type warning + diff --git a/mqtt/config_templates/protected/mosquitto.conf b/mqtt/config_templates/protected/mosquitto.conf new file mode 100644 index 0000000..ac1f7f3 --- /dev/null +++ b/mqtt/config_templates/protected/mosquitto.conf @@ -0,0 +1,12 @@ +listener 1883 +persistence true +persistence_location /mosquitto/data/ + +## Authentication ## +# Create passwd file: mosquitto_passwd -c /mosquitto/config/passwd +# You need to make down && make up to use the new passwd file +password_file /mosquitto/config/passwd + +## Logging - possibilities: error, warning, notice, information, all +log_type warning + diff --git a/mqtt/config_templates/protected/passwd b/mqtt/config_templates/protected/passwd new file mode 100644 index 0000000..e69de29 diff --git a/mqtt/docker-compose.template b/mqtt/docker-compose.template new file mode 100644 index 0000000..cef765b --- /dev/null +++ b/mqtt/docker-compose.template @@ -0,0 +1,19 @@ +#version: '3' +#services: + + mqtt: + build: mqtt + volumes: + - type: bind + source: /home/dirk/tmp/mqtt/ + target: /mosquitto/ + ports: + - target: 1883 + published: 1883 + protocol: tcp + mode: host + - target: 9001 + published: 9001 + protocol: tcp + mode: host +