diff --git a/README.md b/README.md index a93592c..456d0dc 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,23 @@ environment: - DATABASE_URL=sqlite:///./drugs.db ``` +## MQTT + +The system includes an MQTT broker (Mosquitto) with WebSocket support: + +- **MQTT**: `localhost:1883` +- **WebSocket**: `localhost:9001` or `/mqtt` via nginx + +To create a new MQTT user with a custom password: +```bash +docker run --rm -v $(pwd)/mosquitto/config:/temp eclipse-mosquitto mosquitto_passwd -b /temp/pwfile username password +``` + +Then restart the containers: +```bash +docker compose restart mosquitto +``` + ## Development When you run `docker-compose up`, the backend automatically reloads when code changes (`--reload` flag). Just refresh your browser to see updates. diff --git a/docker-compose.yml b/docker-compose.yml index 7cab79a..d290ee8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,8 +5,6 @@ services: build: context: ./backend dockerfile: Dockerfile - ports: - - "${BACKEND_PORT}:8000" volumes: - ./backend/app:/app/app - ./data:/app/data @@ -23,13 +21,38 @@ services: - LABEL_TEMPLATE_ID=${LABEL_TEMPLATE_ID:-vet_label} - LABEL_SIZE=${LABEL_SIZE:-29x90} - LABEL_TEST=${LABEL_TEST:-false} + networks: + - webapps + + mosquitto: + image: eclipse-mosquitto:latest + volumes: + - ./mosquitto/config/mosquitto.conf:/mosquitto/config/mosquitto.conf:ro + - ./mosquitto/config/pwfile:/mosquitto/config/pwfile:ro + - mosquitto_data:/mosquitto/data + - mosquitto_logs:/mosquitto/log + environment: + - PUID=1001 + - PGID=1001 + networks: + - webapps frontend: image: nginx:alpine - ports: - - "${FRONTEND_PORT}:80" + container_name: drugsdev volumes: - ./frontend:/usr/share/nginx/html:ro - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro depends_on: - backend + - mosquitto + networks: + - webapps + +volumes: + mosquitto_data: + mosquitto_logs: + +networks: + webapps: + external: true diff --git a/frontend/app.js b/frontend/app.js index 03cede9..ae29bc3 100644 --- a/frontend/app.js +++ b/frontend/app.js @@ -394,7 +394,7 @@ function renderDrugs() {