This commit is contained in:
hubobel 2026-01-12 16:39:22 +01:00
parent f7fa2c7510
commit 9e1733a96f
3 changed files with 41 additions and 3 deletions

4
.env
View file

@ -5,5 +5,5 @@ INFLUXDB_BUCKET=Temperaturen
INFLUXDB_TOKEN=1wml0Wzrno-VPHxw0N4CSJh42aTAE-zCCAnAj8BLY_YxsmexXO6_8o7i1HDdAPzDUndCCsejWKq9GJXeYFDhpQ== INFLUXDB_TOKEN=1wml0Wzrno-VPHxw0N4CSJh42aTAE-zCCAnAj8BLY_YxsmexXO6_8o7i1HDdAPzDUndCCsejWKq9GJXeYFDhpQ==
# MQTT # MQTT
MQTT_USER=dein_user MQTT_USER=mqtt_user
MQTT_PASS=dein_passwort MQTT_PASS=mqtt_pw

View file

@ -1,6 +1,9 @@
version: "3.9" version: "3.9"
services: services:
# -------------------------------------------------
# InfluxDB
# -------------------------------------------------
influxdb: influxdb:
image: influxdb:latest image: influxdb:latest
container_name: influxdb container_name: influxdb
@ -16,6 +19,10 @@ services:
timeout: 3s timeout: 3s
retries: 20 retries: 20
# -------------------------------------------------
# Grafana
# -------------------------------------------------
grafana: grafana:
image: grafana/grafana:latest image: grafana/grafana:latest
container_name: grafana container_name: grafana
@ -35,10 +42,16 @@ services:
influxdb: influxdb:
condition: service_healthy condition: service_healthy
# -------------------------------------------------
# Mosquitto (MQTT) User wird beim Start angelegt
# -------------------------------------------------
mqtt5: mqtt5:
image: eclipse-mosquitto:latest image: eclipse-mosquitto:latest
container_name: mqtt5 container_name: mqtt5
restart: unless-stopped restart: unless-stopped
env_file:
- .env
ports: ports:
- "1883:1883" - "1883:1883"
- "9001:9001" - "9001:9001"
@ -46,12 +59,31 @@ services:
- ./mosquitto/config:/mosquitto/config - ./mosquitto/config:/mosquitto/config
- ./mosquitto/data:/mosquitto/data - ./mosquitto/data:/mosquitto/data
- ./mosquitto/log:/mosquitto/log - ./mosquitto/log:/mosquitto/log
command: >
sh -c '
if [ ! -f /mosquitto/config/passwd ]; then
echo "Creating MQTT user";
mosquitto_passwd -b /mosquitto/config/passwd "$MQTT_USER" "$MQTT_PASS";
chmod 600 /mosquitto/config/passwd;
fi &&
exec mosquitto -c /mosquitto/config/mosquitto.conf
'
healthcheck: healthcheck:
test: ["CMD-SHELL", "mosquitto_pub -h localhost -p 1883 -t healthcheck/ping -n >/dev/null 2>&1 || exit 1"] test:
[
"CMD-SHELL",
"mosquitto_pub -h localhost -p 1883 -u \"$MQTT_USER\" -P \"$MQTT_PASS\" -q 0 -t healthcheck/ping -n >/dev/null 2>&1 || exit 1"
]
interval: 10s interval: 10s
timeout: 5s timeout: 5s
retries: 12 retries: 12
# -------------------------------------------------
# Telegraf
# -------------------------------------------------
telegraf: telegraf:
image: telegraf:latest image: telegraf:latest
container_name: telegraf container_name: telegraf
@ -71,6 +103,7 @@ services:
timeout: 3s timeout: 3s
retries: 12 retries: 12
networks: networks:
default: default:
name: mqtt5-network name: mqtt5-network

View file

@ -0,0 +1,5 @@
listener 1883
protocol mqtt
allow_anonymous false
password_file /mosquitto/config/passwd