1
0
forked from jchomaz/Vulture

Compare commits

...

9 Commits

22 changed files with 320 additions and 36 deletions

View File

@@ -1,6 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="fr"> <html lang="fr">
<head> <meta charset="UTF-8"> <link rel="icon" href="/favicon.ico"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Brain Blast</title> <head> <meta charset="UTF-8"> <link rel="icon" href="/favicon.ico"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Brain Blast</title>
<script src="/config.js"></script>
</head> </head>
<body> <div id="app"></div> <script type="module" src="/src/main.js"></script> <body> <div id="app"></div> <script type="module" src="/src/main.js"></script>
</body> </body>

7
VApp/public/config.js Normal file
View File

@@ -0,0 +1,7 @@
window.APP_CONFIG = {
mqttBrokerUrl: 'ws://192.168.73.252:9001',
redBuzzerIP: '192.168.73.40',
blueBuzzerIP: '192.168.73.41',
orangeBuzzerIP: '192.168.73.42',
greenBuzzerIP: '192.168.73.43'
};

View File

@@ -1,16 +1,15 @@
// Fichier vide, regarde config.js.example pour personaliser ce fichier.
// Note de dev : Normalement ce fichier ne devrait plus avoir de
// modifications
// config.js // config.js
export default { // Reads configuration from window.APP_CONFIG (loaded via public/config.js)
mqttBrokerUrl: 'ws://192.168.1.30:9001', // This allows runtime configuration changes without rebuilding the app.
// Buzzer const defaults = {
mqttBrokerUrl: 'ws://192.168.73.252:9001',
redBuzzerIP: '192.168.73.40', redBuzzerIP: '192.168.73.40',
blueBuzzerIP: '192.168.73.41', blueBuzzerIP: '192.168.73.41',
orangeBuzzerIP: '192.168.73.42', orangeBuzzerIP: '192.168.73.42',
greenBuzzerIP: '192.168.73.43' greenBuzzerIP: '192.168.73.43'
// Light
}; };
const config = window.APP_CONFIG || defaults;
export default config;

View File

@@ -18,11 +18,11 @@ mqtt {
} }
listeners.tcp { listeners.tcp {
bind = "127.0.0.1:1883" bind = "0.0.0.0:1883"
} }
listeners.ws { listeners.ws {
bind = "127.0.0.1:9001" bind = "0.0.0.0:9001"
} }
http_server { http_server {

View File

@@ -1,31 +1,101 @@
# VContainer - Vulture build script # VContainer - Vulture build script
Construction et lancements des containers. Construction et lancements des containers.
Toutes les commandes sont a tapper depuis la racine du dépot. Toutes les commandes sont à taper depuis la racine du dépôt.
## Build ## Build
```bash
./VContainers/build.sh
```
Ou manuellement :
```bash
podman build . -f ./VContainers/VNode/Containerfile -t vnode podman build . -f ./VContainers/VNode/Containerfile -t vnode
podman build . -f ./VContainers/VApp/Containerfile -t vapp podman build . -f ./VContainers/VApp/Containerfile -t vapp
```
## Run ## Run
Lancement des trois containers dans le même pod, ils partagent le réseau, les différents services sont disponibles sur localhost. ### Mode Manuel avec Scripts
podman pod create --name vulture -p 8080:80 -p 1883:1883 -p 8083:8083 -p 8883:8883 **Développement (localhost):**
podman run -dt --rm --pod vulture --name nanomq -v ./VContainers/MQTT/config/nanomq.conf:/etc/nanomq.conf docker.io/emqx/nanomq:latest ```bash
podman run -dt --rm --pod vulture --name vnode vnode:latest ./VContainers/run_dev.sh
podman run -dt --rm --pod vulture --name vapp vapp:latest ```
**Production (IP 192.168.73.252):**
```bash
./VContainers/run_prod.sh
```
Les containers sont lancés sur le réseau bridge `vulture-net` :
- **nanomq** : Broker MQTT (ports 1883, 9001, 8081, 8083, 8883)
- **vnode** : Services Node.js backend
- **vapp** : Frontend Vue.js (port 8080)
## Stop ## Stop
podman stop vapp ```bash
podman stop vnode ./VContainers/stop.sh
podman stop nanomq ```
podman pod rm vulture
Ou manuellement :
```bash
podman stop vapp vnode nanomq
podman network rm vulture-net
```
## Lancement automatique avec Quadlet
Copier les fichiers du répertoire `quadlet` vers `~/.config/containers/systemd/`
```bash
cp ./VContainers/quadlet/*.network ~/.config/containers/systemd/
cp ./VContainers/quadlet/*.container ~/.config/containers/systemd/
```
**Pour l'environnement de développement :**
```bash
systemctl --user daemon-reload
systemctl --user enable --now nanomq.service
systemctl --user enable --now vnode.service
systemctl --user enable --now vapp_dev.service
```
**Pour l'environnement de production :**
```bash
systemctl --user daemon-reload
systemctl --user enable --now nanomq.service
systemctl --user enable --now vnode.service
systemctl --user enable --now vapp_prod.service
```
**Vérifier le statut :**
```bash
systemctl --user status nanomq.service vnode.service vapp_dev.service
```
**Arrêter les services :**
```bash
systemctl --user stop vapp_dev.service vnode.service nanomq.service
systemctl --user disable vapp_dev.service vnode.service nanomq.service
```
## Configuration
Les fichiers de configuration se trouvent dans `VContainers/VApp/config/` :
- `config_dev.js` : Configuration développement (MQTT sur localhost)
- `config_prod.js` : Configuration production (MQTT sur 192.168.73.252)
Vous pouvez modifier ces fichiers selon vos besoins. En mode manuel, redémarrez les containers. Avec Quadlet, redémarrez le service correspondant :
```bash
systemctl --user restart vapp_dev.service
```
## Tip ## Tip
Pour permettre à Podman d'utiliser les ports privilégiés (<1024) :
```bash
sudo sysctl -w net.ipv4.ip_unprivileged_port_start=80 sudo sysctl -w net.ipv4.ip_unprivileged_port_start=80
```

View File

@@ -0,0 +1,11 @@
window.APP_CONFIG = {
// URL du broker MQTT (WebSockets)
// Configuration DEV : localhost
mqttBrokerUrl: 'ws://localhost:9001',
// IPs des buzzers
redBuzzerIP: '192.168.73.40',
blueBuzzerIP: '192.168.73.41',
orangeBuzzerIP: '192.168.73.42',
greenBuzzerIP: '192.168.73.43'
};

View File

@@ -0,0 +1,11 @@
window.APP_CONFIG = {
// URL du broker MQTT (WebSockets)
// Configuration PROD : IP du serveur
mqttBrokerUrl: 'ws://192.168.73.252:9001',
// IPs des buzzers
redBuzzerIP: '192.168.73.40',
blueBuzzerIP: '192.168.73.41',
orangeBuzzerIP: '192.168.73.42',
greenBuzzerIP: '192.168.73.43'
};

13
VContainers/build.sh Executable file
View File

@@ -0,0 +1,13 @@
#!/bin/bash
set -e
# Move to repository root
cd "$(dirname "$0")/.."
echo "Building VNode..."
podman build . -f ./VContainers/VNode/Containerfile -t vnode
echo "Building VApp..."
podman build . -f ./VContainers/VApp/Containerfile -t vapp
echo "Build complete."

View File

@@ -0,0 +1,19 @@
[Unit]
Description=Broker MQTT NanoMQ
Wants=network-online.target
After=network-online.target
[Container]
Image=docker.io/emqx/nanomq:latest
ContainerName=nanomq
Network=vulture-net.network
PublishPort=1883:1883
PublishPort=9001:9001
PublishPort=8081:8081
PublishPort=8083:8083
PublishPort=8883:8883
Volume=%h/Src/Fablab/Vulture/VContainers/MQTT/config/nanomq.conf:/etc/nanomq.conf:Z
Exec=--conf /etc/nanomq.conf
[Install]
WantedBy=default.target

View File

@@ -0,0 +1,12 @@
[Unit]
Description=Application Node.js VApp
Requires=vulture.pod
After=vulture.pod
[Container]
Image=localhost/vapp:latest
ContainerName=vapp
Pod=vulture
[Install]
WantedBy=vulture.pod

View File

@@ -0,0 +1,16 @@
[Unit]
Description=Application Vue.js VApp (DEV)
Wants=network-online.target
After=network-online.target
Requires=nanomq.service
After=nanomq.service
[Container]
Image=localhost/vapp:latest
ContainerName=vapp
Network=vulture-net.network
PublishPort=8080:80
Volume=%h/Src/Fablab/Vulture/VContainers/VApp/config/config_dev.js:/usr/share/nginx/html/config.js:Z
[Install]
WantedBy=default.target

View File

@@ -0,0 +1,16 @@
[Unit]
Description=Application Vue.js VApp (PROD)
Wants=network-online.target
After=network-online.target
Requires=nanomq.service
After=nanomq.service
[Container]
Image=localhost/vapp:latest
ContainerName=vapp
Network=vulture-net.network
PublishPort=8080:80
Volume=%h/Src/Fablab/Vulture/VContainers/VApp/config/config_prod.js:/usr/share/nginx/html/config.js:Z
[Install]
WantedBy=default.target

View File

@@ -0,0 +1,14 @@
[Unit]
Description=Application Node.js VNode
Wants=network-online.target
After=network-online.target
Requires=nanomq.service
After=nanomq.service
[Container]
Image=localhost/vnode:latest
ContainerName=vnode
Network=vulture-net.network
[Install]
WantedBy=default.target

View File

@@ -0,0 +1,6 @@
[Unit]
Description=Reseau Bridge pour Vulture
[Network]
NetworkName=vulture-net
Driver=bridge

View File

@@ -0,0 +1,14 @@
[Unit]
Description=Pod Vulture pour le Broker MQTT et les Applications Node
Wants=network-online.target
After=network-online.target
[Pod]
# Mappings de ports : Host:Container (ces ports sont partagés par tous les conteneurs)
PublishPort=8080:80
PublishPort=1883:1883
PublishPort=8083:8083
PublishPort=8883:8883
[Install]
WantedBy=default.target

33
VContainers/run_dev.sh Executable file
View File

@@ -0,0 +1,33 @@
#!/bin/bash
set -e
# Move to repository root
cd "$(dirname "$0")/.."
NETWORK_NAME="vulture-net"
echo "Creating network $NETWORK_NAME..."
if podman network exists $NETWORK_NAME; then
echo "Network $NETWORK_NAME already exists."
else
podman network create $NETWORK_NAME
fi
echo "Starting NanoMQ..."
# NanoMQ needs to expose ports for external access (e.g. VApp frontend) and be on the network for VNode
podman run -dt --rm --network $NETWORK_NAME --name nanomq \
-p 1883:1883 -p 9001:9001 -p 8081:8081 -p 8083:8083 -p 8883:8883 \
-v ./VContainers/MQTT/config/nanomq.conf:/etc/nanomq.conf:Z \
docker.io/emqx/nanomq:latest --conf /etc/nanomq.conf
echo "Starting VNode..."
# VNode connects to nanomq via the network, no ports needed on host unless for debugging
podman run -dt --rm --network $NETWORK_NAME --name vnode vnode:latest
echo "Starting VApp (DEV CONFIG)..."
# VApp (nginx) needs port 80 exposed
podman run -dt --rm --network $NETWORK_NAME --name vapp -p 8080:80 \
-v ./VContainers/VApp/config/config_dev.js:/usr/share/nginx/html/config.js:Z \
vapp:latest
echo "All containers started on network $NETWORK_NAME with DEV configuration."

33
VContainers/run_prod.sh Executable file
View File

@@ -0,0 +1,33 @@
#!/bin/bash
set -e
# Move to repository root
cd "$(dirname "$0")/.."
NETWORK_NAME="vulture-net"
echo "Creating network $NETWORK_NAME..."
if podman network exists $NETWORK_NAME; then
echo "Network $NETWORK_NAME already exists."
else
podman network create $NETWORK_NAME
fi
echo "Starting NanoMQ..."
# NanoMQ needs to expose ports for external access (e.g. VApp frontend) and be on the network for VNode
podman run -dt --rm --network $NETWORK_NAME --name nanomq \
-p 1883:1883 -p 9001:9001 -p 8081:8081 -p 8083:8083 -p 8883:8883 \
-v ./VContainers/MQTT/config/nanomq.conf:/etc/nanomq.conf:Z \
docker.io/emqx/nanomq:latest --conf /etc/nanomq.conf
echo "Starting VNode..."
# VNode connects to nanomq via the network, no ports needed on host unless for debugging
podman run -dt --rm --network $NETWORK_NAME --name vnode vnode:latest
echo "Starting VApp (PROD CONFIG)..."
# VApp (nginx) needs port 80 exposed
podman run -dt --rm --network $NETWORK_NAME --name vapp -p 8080:80 \
-v ./VContainers/VApp/config/config_prod.js:/usr/share/nginx/html/config.js:Z \
vapp:latest
echo "All containers started on network $NETWORK_NAME with PROD configuration."

11
VContainers/stop.sh Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/bash
echo "Stopping containers..."
podman stop vapp || echo "vapp not running"
podman stop vnode || echo "vnode not running"
podman stop nanomq || echo "nanomq not running"
echo "Removing network..."
podman network rm vulture-net || echo "Network vulture-net not found"
echo "Cleanup complete."

View File

@@ -2,7 +2,7 @@
const mqtt = require('mqtt'); const mqtt = require('mqtt');
// MQTT broker configuration // MQTT broker configuration
const brokerUrl = 'mqtt://localhost'; // Broker URL (change if needed) const brokerUrl = 'mqtt://nanomq'; // Broker URL (change if needed)
const clientId = 'buzzer_manager'; const clientId = 'buzzer_manager';
const options = { const options = {
clientId, clientId,

View File

@@ -1,18 +1,17 @@
{ {
"services": { "services": {
"mqttHost": "mqtt://localhost", "mqttHost": "mqtt://nanomq",
"score":{ "score": {
"MQTTconfig":{ "MQTTconfig": {
"mqttScoreTopic": "game/score", "mqttScoreTopic": "game/score",
"mqttScoreChangeTopic": "game/score/update" "mqttScoreChangeTopic": "game/score/update"
} }
}, },
"quizzcollector":{ "quizzcollector": {
"MQTTconfig":{ "MQTTconfig": {
"mqttQuizzCollectorListTopic": "game/quizz-collector/list", "mqttQuizzCollectorListTopic": "game/quizz-collector/list",
"mqttQuizzCollectorCmdTopic": "game/quizz-collector/cmd" "mqttQuizzCollectorCmdTopic": "game/quizz-collector/cmd"
} }
} }
} }
} }

View File

@@ -1,17 +1,16 @@
{ {
"hosts": { "hosts": {
"buzzers":{ "buzzers": {
"IP":{ "IP": {
"redBuzzerIP": "8.8.8.6", "redBuzzerIP": "8.8.8.6",
"blueBuzzerIP": "8.8.8.8", "blueBuzzerIP": "8.8.8.8",
"greenBuzzerIP": "8.8.8.8", "greenBuzzerIP": "8.8.8.8",
"yellowBuzzerIP": "8.8.8.8" "yellowBuzzerIP": "8.8.8.8"
}, },
"MQTTconfig":{ "MQTTconfig": {
"mqttHost": "mqtt://localhost", "mqttHost": "mqtt://nanomq",
"mqttTopic": "buzzer/watcher" "mqttTopic": "buzzer/watcher"
} }
} }
} }
} }

View File

@@ -2,7 +2,7 @@
const mqtt = require('mqtt'); const mqtt = require('mqtt');
// Configuration du broker MQTT et de WLED // Configuration du broker MQTT et de WLED
const brokerUrl = 'mqtt://localhost'; // Change ce lien si nécessaire const brokerUrl = 'mqtt://nanomq'; // Change ce lien si nécessaire
const clientId = 'light_manager_wled'; const clientId = 'light_manager_wled';
const wledTopicBase = 'wled/all'; // Le topic de base pour ton ruban WLED const wledTopicBase = 'wled/all'; // Le topic de base pour ton ruban WLED
const options = { const options = {