docker: add wait-for-mqtt entrypoint; remove compose override

This commit is contained in:
2025-12-28 15:17:28 +01:00
parent 0135924f7f
commit 79fcf7389f
3 changed files with 28 additions and 4 deletions

22
scripts/wait-for-mqtt.sh Normal file
View File

@@ -0,0 +1,22 @@
#!/bin/sh
# wait-for-mqtt.sh: wait for MQTT broker from $MQTT_BROKER (default tcp://mosquitto:1883)
set -e
BROKER=${MQTT_BROKER:-tcp://mosquitto:1883}
# strip tcp:// if present
BROKER=${BROKER#tcp://}
HOST=${BROKER%%:*}
PORT=${BROKER#*:}
if [ "$HOST" = "$PORT" ]; then
# no port provided
PORT=1883
fi
echo "Waiting for MQTT broker $HOST:$PORT..."
while ! nc -z "$HOST" "$PORT"; do
echo "broker not ready, retrying..."
sleep 1
done
echo "Broker $HOST:$PORT is up, starting server"
exec /usr/local/bin/server