This is a poor-mans self-hosted version of shiftr.io
- Node.js
Make sure you have Node.js installed on your machine. You can download it from nodejs.org.
- MQTT broker
For this project to run, make sure there is a MQTT broker running which you can connect to.
- Docker
Preferably the Mosquitto
broker is used from the docker-compose
file. You can install docker-desktop.
docker-compose up -d mosquitto
First, install the dependencies:
npm i
Then start the server:
npm run dev
To run the project in docker, run the following command:
docker-compose up -d --build
This Docker-container will build and run the server.
The server is responsible for reading the Mosquitto
log-stream and re-publishing the messages to the client.
This Docker-container will only build the client files and put them at /src/client/dist/
.
It could be served by a web-server like nginx
or apache
.
Or temporarily by running the following commands:
npm install http-server -g
# From within the src/client/dist folder
http-server -p 8080
This Docker-container will run the Mosquitto
broker.
The most important settings in the mosquitto.conf
are:
log_type all
-- making sure all internal actions are exposed to theserver
.log_dest file /mosquitto/log/mosquitto.log
-- making sure the log is written to a file which theserver
has access to.
The default user configured is username:password
.
# Encrypt the password file
docker exec mosquitto mosquitto_passwd -U /mosquitto/config/passwd
# Add a user
docker exec mosquitto mosquitto_passwd -b /mosquitto/config/passwd user password