test: enable mosquitto password auth; add mqttping endpoint; use credentials in subscriber; publish defaults
This commit is contained in:
@@ -14,6 +14,8 @@ services:
|
||||
- MQTT_BROKER=tcp://mosquitto:1883
|
||||
- MQTT_CLIENT_ID=lambdaiot-server
|
||||
- MQTT_TOPIC=lambdaiot
|
||||
- MQTT_USERNAME=testuser
|
||||
- MQTT_PASSWORD=testpass
|
||||
depends_on:
|
||||
- mosquitto
|
||||
# server image now waits for MQTT broker itself via entrypoint
|
||||
@@ -27,6 +29,8 @@ services:
|
||||
- mosquitto_data:/mosquitto/data
|
||||
- mosquitto_log:/mosquitto/log
|
||||
- ./mosquitto.conf:/mosquitto/config/mosquitto.conf:ro
|
||||
# ensure a password file exists and start mosquitto with our config
|
||||
command: sh -c "mosquitto_passwd -b /mosquitto/config/passwordfile testuser testpass >/dev/null 2>&1 || true; /usr/sbin/mosquitto -c /mosquitto/config/mosquitto.conf"
|
||||
healthcheck:
|
||||
test: ["CMD", "sh", "-c", "nc -z localhost 1883 || exit 1"]
|
||||
interval: 2s
|
||||
@@ -41,6 +45,8 @@ services:
|
||||
environment:
|
||||
- MQTT_BROKER=mosquitto:1883
|
||||
- MQTT_TOPIC=lambdaiot
|
||||
- MQTT_USERNAME=testuser
|
||||
- MQTT_PASSWORD=testpass
|
||||
command: sh -c "pip install paho-mqtt && python subscribe.py"
|
||||
depends_on:
|
||||
- mosquitto
|
||||
|
||||
Reference in New Issue
Block a user