1
0
forked from jchomaz/Vulture

6 Commits

19 changed files with 204 additions and 26 deletions

View File

@@ -1,6 +1,7 @@
<!DOCTYPE html>
<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>
<script src="/config.js"></script>
</head>
<body> <div id="app"></div> <script type="module" src="/src/main.js"></script>
</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
export default {
mqttBrokerUrl: 'ws://192.168.73.252:9001',
// Reads configuration from window.APP_CONFIG (loaded via public/config.js)
// This allows runtime configuration changes without rebuilding the app.
// Buzzer
const defaults = {
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'
// Light
};
const config = window.APP_CONFIG || defaults;
export default config;

View File

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

View File

@@ -14,8 +14,8 @@ podman build . -f ./VContainers/VApp/Containerfile -t vapp
Lancement des trois containers dans le même pod, ils partagent le réseau, les différents services sont disponibles sur localhost.
podman pod create --name vulture -p 8080:80 -p 1883:1883 -p 8083:8083 -p 8883:8883
podman run -dt --rm --pod vulture --name nanomq -v ./VContainers/MQTT/config/nanomq.conf:/etc/nanomq.conf docker.io/emqx/nanomq:latest
podman pod create --name vulture -p 8080:80 -p 1883:1883 -p 8081:8081 -p 8083:8083 -p 8883:8883 -p 9001:9001
podman run -dt --rm --pod vulture --name nanomq -v ./VContainers/MQTT/config/nanomq.conf:/etc/nanomq.conf docker.io/emqx/nanomq:latest --conf /etc/nanomq.conf
podman run -dt --rm --pod vulture --name vnode vnode:latest
podman run -dt --rm --pod vulture --name vapp vapp:latest
@@ -26,6 +26,15 @@ podman stop vnode
podman stop nanomq
podman pod rm vulture
## Lancement automatique avec Quadlet
Copier les fichiers du repertoire quadlet vers ~/.config/containers/systemd/
```
systemctl --user daemon-reload
systemctl --user enable --now vulture.pod
```
## Tip
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,14 @@
[Unit]
Description=Broker MQTT NanoMQ
Requires=vulture.pod
After=vulture.pod
[Container]
Image=docker.io/emqx/nanomq:latest
ContainerName=nanomq
Pod=vulture
# Correspond à -v ./VContainers/MQTT/config/nanomq.conf:/etc/nanomq.conf
Volume=./VContainers/MQTT/config/nanomq.conf:/etc/nanomq.conf
[Install]
WantedBy=vulture.pod

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,12 @@
[Unit]
Description=Application Node.js VNode
Requires=vulture.pod
After=vulture.pod
[Container]
Image=localhost/vnode:latest
ContainerName=vnode
Pod=vulture
[Install]
WantedBy=vulture.pod

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');
// 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 options = {
clientId,

View File

@@ -1,6 +1,6 @@
{
"services": {
"mqttHost": "mqtt://localhost",
"mqttHost": "mqtt://nanomq",
"score": {
"MQTTconfig": {
"mqttScoreTopic": "game/score",
@@ -14,5 +14,4 @@
}
}
}
}

View File

@@ -8,10 +8,9 @@
"yellowBuzzerIP": "8.8.8.8"
},
"MQTTconfig": {
"mqttHost": "mqtt://localhost",
"mqttHost": "mqtt://nanomq",
"mqttTopic": "buzzer/watcher"
}
}
}
}

View File

@@ -2,7 +2,7 @@
const mqtt = require('mqtt');
// 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 wledTopicBase = 'wled/all'; // Le topic de base pour ton ruban WLED
const options = {