npm install
npm run-script fix
npm test
npm run
Populate a mqtt-demo/.env
file:
MQTT_SERVER_URL=mqtt://mosquitto
MQTT_USERNAME=
MQTT_PASSWORD=
PGHOST=postgres
PGUSER=iot
PGPASSWORD=CRxVcSPsB704
PGDATABASE=iot
cd mqtt-demo/
docker-compose pull
docker-compose build --pull
docker-compose up
# When done, [CONTROL]+[C]
docker-compose down --volumes
In another process:
docker exec mosquitto mosquitto_pub -t 'test' -m '{"Hello": "World"}'
Optionally, in yet another process, listen to MQTT:
docker exec mosquitto mosquitto_sub -t '#' -v
docker exec postgres psql -d iot -U iot -c 'SELECT * FROM mqtt ORDER BY id DESC LIMIT 10;'
docker exec -it postgres psql -d iot -U iot
\dt
ALTER TABLE mqtt ADD COLUMN comment TEXT;
Or re-run the init script if it was modified:
docker exec postgres psql -d iot -U iot -a -f /docker-entrypoint-initdb.d/mqtt.sql