forked from jchomaz/Vulture
Compare commits
19 Commits
8baf0cbdd7
...
container-
| Author | SHA1 | Date | |
|---|---|---|---|
| 01d38545ac | |||
| 31911a56d2 | |||
| 10a04de1e6 | |||
| 6633ecbe70 | |||
| 516ca23c5e | |||
| f0b828a615 | |||
| 7c5a1d7c6b | |||
| da929ecb89 | |||
| 4ab0cca1b2 | |||
| 5401f416e7 | |||
| 856b90567d | |||
| bb791ed2f4 | |||
| 768f42dff4 | |||
| bc807f9c7b | |||
| 8d980a90c8 | |||
| e8607c78e9 | |||
| 1ff31e0991 | |||
| 3e29bfca18 | |||
| 56c6a744c7 |
142
.gitignore
vendored
Normal file
142
.gitignore
vendored
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
# Score files
|
||||||
|
/VNode/services/game/score/*.json
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||||
|
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||||
|
|
||||||
|
# Runtime data
|
||||||
|
pids
|
||||||
|
*.pid
|
||||||
|
*.seed
|
||||||
|
*.pid.lock
|
||||||
|
|
||||||
|
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||||
|
lib-cov
|
||||||
|
|
||||||
|
# Coverage directory used by tools like istanbul
|
||||||
|
coverage
|
||||||
|
*.lcov
|
||||||
|
|
||||||
|
# nyc test coverage
|
||||||
|
.nyc_output
|
||||||
|
|
||||||
|
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||||
|
.grunt
|
||||||
|
|
||||||
|
# Bower dependency directory (https://bower.io/)
|
||||||
|
bower_components
|
||||||
|
|
||||||
|
# node-waf configuration
|
||||||
|
.lock-wscript
|
||||||
|
|
||||||
|
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||||
|
build/Release
|
||||||
|
|
||||||
|
# Dependency directories
|
||||||
|
node_modules/
|
||||||
|
jspm_packages/
|
||||||
|
|
||||||
|
# Snowpack dependency directory (https://snowpack.dev/)
|
||||||
|
web_modules/
|
||||||
|
|
||||||
|
# TypeScript cache
|
||||||
|
*.tsbuildinfo
|
||||||
|
|
||||||
|
# Optional npm cache directory
|
||||||
|
.npm
|
||||||
|
|
||||||
|
# Optional eslint cache
|
||||||
|
.eslintcache
|
||||||
|
|
||||||
|
# Optional stylelint cache
|
||||||
|
.stylelintcache
|
||||||
|
|
||||||
|
# Optional REPL history
|
||||||
|
.node_repl_history
|
||||||
|
|
||||||
|
# Output of 'npm pack'
|
||||||
|
*.tgz
|
||||||
|
|
||||||
|
# Yarn Integrity file
|
||||||
|
.yarn-integrity
|
||||||
|
|
||||||
|
# dotenv environment variable files
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
|
!.env.example
|
||||||
|
|
||||||
|
# parcel-bundler cache (https://parceljs.org/)
|
||||||
|
.cache
|
||||||
|
.parcel-cache
|
||||||
|
|
||||||
|
# Next.js build output
|
||||||
|
.next
|
||||||
|
out
|
||||||
|
|
||||||
|
# Nuxt.js build / generate output
|
||||||
|
.nuxt
|
||||||
|
dist
|
||||||
|
|
||||||
|
# Gatsby files
|
||||||
|
.cache/
|
||||||
|
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||||
|
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||||
|
# public
|
||||||
|
|
||||||
|
# vuepress build output
|
||||||
|
.vuepress/dist
|
||||||
|
|
||||||
|
# vuepress v2.x temp and cache directory
|
||||||
|
.temp
|
||||||
|
.cache
|
||||||
|
|
||||||
|
# Sveltekit cache directory
|
||||||
|
.svelte-kit/
|
||||||
|
|
||||||
|
# vitepress build output
|
||||||
|
**/.vitepress/dist
|
||||||
|
|
||||||
|
# vitepress cache directory
|
||||||
|
**/.vitepress/cache
|
||||||
|
|
||||||
|
# Docusaurus cache and generated files
|
||||||
|
.docusaurus
|
||||||
|
|
||||||
|
# Serverless directories
|
||||||
|
.serverless/
|
||||||
|
|
||||||
|
# FuseBox cache
|
||||||
|
.fusebox/
|
||||||
|
|
||||||
|
# DynamoDB Local files
|
||||||
|
.dynamodb/
|
||||||
|
|
||||||
|
# Firebase cache directory
|
||||||
|
.firebase/
|
||||||
|
|
||||||
|
# TernJS port file
|
||||||
|
.tern-port
|
||||||
|
|
||||||
|
# Stores VSCode versions used for testing VSCode extensions
|
||||||
|
.vscode-test
|
||||||
|
|
||||||
|
# yarn v3
|
||||||
|
.pnp.*
|
||||||
|
.yarn/*
|
||||||
|
!.yarn/patches
|
||||||
|
!.yarn/plugins
|
||||||
|
!.yarn/releases
|
||||||
|
!.yarn/sdks
|
||||||
|
!.yarn/versions
|
||||||
|
|
||||||
|
# Vite logs files
|
||||||
|
vite.config.js.timestamp-*
|
||||||
|
vite.config.ts.timestamp-*
|
||||||
@@ -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>
|
||||||
|
|||||||
3590
VApp/package-lock.json
generated
3590
VApp/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -12,27 +12,27 @@
|
|||||||
"format": "prettier --write src/"
|
"format": "prettier --write src/"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@mdi/font": "^7.4.47",
|
"@mdi/font": "latest",
|
||||||
"@videojs-player/vue": "^1.0.0",
|
"@videojs-player/vue": "latest",
|
||||||
"express": "^5.0.0",
|
"express": "latest",
|
||||||
"mqtt": "^5.3.5",
|
"mqtt": "latest",
|
||||||
"ping": "^0.4.4",
|
"ping": "latest",
|
||||||
"roboto-fontface": "^0.10.0",
|
"roboto-fontface": "latest",
|
||||||
"video.js": "^8.22.0",
|
"video.js": "latest",
|
||||||
"vue": "^3.4.19",
|
"vue": "latest",
|
||||||
"vue-router": "^4.2.5",
|
"vue-router": "latest",
|
||||||
"vuex": "^4.1.0"
|
"vuex": "latest"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@rushstack/eslint-patch": "^1.3.3",
|
"@rushstack/eslint-patch": "latest",
|
||||||
"@vitejs/plugin-vue": "^5.0.3",
|
"@vitejs/plugin-vue": "latest",
|
||||||
"@vue/eslint-config-prettier": "^8.0.0",
|
"@vue/eslint-config-prettier": "latest",
|
||||||
"concurrently": "^8.2.2",
|
"concurrently": "latest",
|
||||||
"eslint": "^8.49.0",
|
"eslint": "latest",
|
||||||
"eslint-plugin-vue": "^9.17.0",
|
"eslint-plugin-vue": "latest",
|
||||||
"prettier": "^3.0.3",
|
"prettier": "latest",
|
||||||
"unplugin-fonts": "^1.1.1",
|
"unplugin-fonts": "latest",
|
||||||
"vite": "^5.1.6",
|
"vite": "latest",
|
||||||
"vite-plugin-vuetify": "^2.0.1"
|
"vite-plugin-vuetify": "latest"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
7
VApp/public/config.js
Normal file
7
VApp/public/config.js
Normal 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'
|
||||||
|
};
|
||||||
|
Before Width: | Height: | Size: 766 KiB After Width: | Height: | Size: 766 KiB |
@@ -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;
|
||||||
|
|||||||
60
VContainers/MQTT/config/nanomq.conf
Normal file
60
VContainers/MQTT/config/nanomq.conf
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
# NanoMQ Configuration 0.18.0
|
||||||
|
|
||||||
|
# #============================================================
|
||||||
|
# # NanoMQ Broker
|
||||||
|
# #============================================================
|
||||||
|
|
||||||
|
mqtt {
|
||||||
|
property_size = 32
|
||||||
|
max_packet_size = 260MB
|
||||||
|
max_mqueue_len = 2048
|
||||||
|
retry_interval = 10s
|
||||||
|
keepalive_multiplier = 1.25
|
||||||
|
|
||||||
|
# Three of below, unsupported now
|
||||||
|
max_inflight_window = 2048
|
||||||
|
max_awaiting_rel = 10s
|
||||||
|
await_rel_timeout = 10s
|
||||||
|
}
|
||||||
|
|
||||||
|
listeners.tcp {
|
||||||
|
bind = "0.0.0.0:1883"
|
||||||
|
}
|
||||||
|
|
||||||
|
listeners.ws {
|
||||||
|
bind = "0.0.0.0:9001"
|
||||||
|
}
|
||||||
|
|
||||||
|
http_server {
|
||||||
|
port = 8081
|
||||||
|
limit_conn = 2
|
||||||
|
username = admin
|
||||||
|
password = public
|
||||||
|
auth_type = basic
|
||||||
|
jwt {
|
||||||
|
public.keyfile = "/etc/certs/jwt/jwtRS256.key.pub"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log {
|
||||||
|
# to = [file, console]
|
||||||
|
to = [console]
|
||||||
|
level = warn
|
||||||
|
dir = "/tmp"
|
||||||
|
file = "nanomq.log"
|
||||||
|
rotation {
|
||||||
|
size = 10MB
|
||||||
|
count = 5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auth {
|
||||||
|
allow_anonymous = true
|
||||||
|
no_match = allow
|
||||||
|
deny_action = ignore
|
||||||
|
|
||||||
|
cache = {
|
||||||
|
max_size = 32
|
||||||
|
ttl = 1m
|
||||||
|
}
|
||||||
|
}
|
||||||
101
VContainers/README.md
Normal file
101
VContainers/README.md
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
# VContainer - Vulture build script
|
||||||
|
|
||||||
|
Construction et lancements des containers.
|
||||||
|
Toutes les commandes sont à taper depuis la racine du dépôt.
|
||||||
|
|
||||||
|
## Build
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./VContainers/build.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
Ou manuellement :
|
||||||
|
```bash
|
||||||
|
podman build . -f ./VContainers/VNode/Containerfile -t vnode
|
||||||
|
podman build . -f ./VContainers/VApp/Containerfile -t vapp
|
||||||
|
```
|
||||||
|
|
||||||
|
## Run
|
||||||
|
|
||||||
|
### Mode Manuel avec Scripts
|
||||||
|
|
||||||
|
**Développement (localhost):**
|
||||||
|
```bash
|
||||||
|
./VContainers/run_dev.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
**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
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./VContainers/stop.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
Pour permettre à Podman d'utiliser les ports privilégiés (<1024) :
|
||||||
|
```bash
|
||||||
|
sudo sysctl -w net.ipv4.ip_unprivileged_port_start=80
|
||||||
|
```
|
||||||
18
VContainers/VApp/Containerfile
Normal file
18
VContainers/VApp/Containerfile
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#FROM docker.io/nginx:stable-alpine
|
||||||
|
FROM docker.io/node:lts-alpine AS builder
|
||||||
|
## Bundle APP files
|
||||||
|
WORKDIR /app
|
||||||
|
COPY VApp ./
|
||||||
|
RUN npm install
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
FROM docker.io/nginx:stable-alpine
|
||||||
|
RUN rm /etc/nginx/conf.d/default.conf
|
||||||
|
COPY ./VContainers/VApp/nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||||
|
|
||||||
|
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
# CMD ["npm","run","dev"]
|
||||||
|
#CMD ["sleep", "1000"]
|
||||||
11
VContainers/VApp/config/config_dev.js
Normal file
11
VContainers/VApp/config/config_dev.js
Normal 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'
|
||||||
|
};
|
||||||
11
VContainers/VApp/config/config_prod.js
Normal file
11
VContainers/VApp/config/config_prod.js
Normal 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'
|
||||||
|
};
|
||||||
24
VContainers/VApp/nginx.conf
Normal file
24
VContainers/VApp/nginx.conf
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
root /usr/share/nginx/html; # Chemin où les fichiers statiques sont copiés
|
||||||
|
|
||||||
|
index index.html index.htm; # Fichier par défaut à servir
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.html; # Pour les applications SPA (Single Page Applications)
|
||||||
|
# cela redirige toutes les requêtes non trouvées vers index.html
|
||||||
|
}
|
||||||
|
|
||||||
|
# Cache Control pour les fichiers statiques (optionnel mais bonne pratique)
|
||||||
|
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
|
||||||
|
expires 30d;
|
||||||
|
add_header Cache-Control "public, no-transform";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Gzip compression (optionnel, améliore la performance)
|
||||||
|
gzip on;
|
||||||
|
gzip_vary on;
|
||||||
|
gzip_proxied any;
|
||||||
|
gzip_comp_level 6;
|
||||||
|
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
||||||
|
}
|
||||||
12
VContainers/VNode/Containerfile
Normal file
12
VContainers/VNode/Containerfile
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
FROM docker.io/keymetrics/pm2:latest-alpine
|
||||||
|
|
||||||
|
## Bundle APP files
|
||||||
|
COPY VNode src
|
||||||
|
#COPY package.json .
|
||||||
|
COPY VContainers/VNode/pm2.json .
|
||||||
|
#
|
||||||
|
## Install app dependencies
|
||||||
|
RUN cd /src && npm install
|
||||||
|
|
||||||
|
CMD [ "pm2-runtime", "start", "pm2.json" ]
|
||||||
|
#CMD [ "sh"]
|
||||||
44
VContainers/VNode/pm2.json
Normal file
44
VContainers/VNode/pm2.json
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "buzzer-manager",
|
||||||
|
"script": "services/buzzer/buzzer-manager.js",
|
||||||
|
"cwd": "/src",
|
||||||
|
"watch": false,
|
||||||
|
"env": {
|
||||||
|
"NODE_ENV": "production"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "buzzer-watcher",
|
||||||
|
"script": "services/buzzer/buzzer-watcher.js",
|
||||||
|
"cwd": "/src",
|
||||||
|
"watch": false,
|
||||||
|
"env": {
|
||||||
|
"NODE_ENV": "production"
|
||||||
|
} },
|
||||||
|
{
|
||||||
|
"name": "quizz-collector",
|
||||||
|
"script": "services/game/quizz-collector.js",
|
||||||
|
"cwd": "/src",
|
||||||
|
"watch": false,
|
||||||
|
"env": {
|
||||||
|
"NODE_ENV": "production"
|
||||||
|
} },
|
||||||
|
{
|
||||||
|
"name": "score-manager",
|
||||||
|
"script": "services/game/score-manager.js",
|
||||||
|
"cwd": "src",
|
||||||
|
"env": {
|
||||||
|
"NODE_ENV": "production"
|
||||||
|
},
|
||||||
|
"watch": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "light-manager",
|
||||||
|
"script": "services/light/light-manager.js",
|
||||||
|
"cwd": "/src",
|
||||||
|
"watch": false,
|
||||||
|
"env": {
|
||||||
|
"NODE_ENV": "production"
|
||||||
|
} }
|
||||||
|
]
|
||||||
13
VContainers/build.sh
Executable file
13
VContainers/build.sh
Executable 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."
|
||||||
19
VContainers/quadlet/nanomq.container
Normal file
19
VContainers/quadlet/nanomq.container
Normal 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
|
||||||
12
VContainers/quadlet/vapp.container
Normal file
12
VContainers/quadlet/vapp.container
Normal 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
|
||||||
16
VContainers/quadlet/vapp_dev.container
Normal file
16
VContainers/quadlet/vapp_dev.container
Normal 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
|
||||||
16
VContainers/quadlet/vapp_prod.container
Normal file
16
VContainers/quadlet/vapp_prod.container
Normal 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
|
||||||
14
VContainers/quadlet/vnode.container
Normal file
14
VContainers/quadlet/vnode.container
Normal 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
|
||||||
6
VContainers/quadlet/vulture-net.network
Normal file
6
VContainers/quadlet/vulture-net.network
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Reseau Bridge pour Vulture
|
||||||
|
|
||||||
|
[Network]
|
||||||
|
NetworkName=vulture-net
|
||||||
|
Driver=bridge
|
||||||
14
VContainers/quadlet/vulture.pod
Normal file
14
VContainers/quadlet/vulture.pod
Normal 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
33
VContainers/run_dev.sh
Executable 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
33
VContainers/run_prod.sh
Executable 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
11
VContainers/stop.sh
Executable 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."
|
||||||
@@ -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,
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
|
const path = require('path');
|
||||||
const ping = require('ping');
|
const ping = require('ping');
|
||||||
const mqtt = require('mqtt');
|
const mqtt = require('mqtt');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
// Lecture du fichier de configuration
|
// Lecture du fichier de configuration
|
||||||
const config = JSON.parse(fs.readFileSync('\services\\config\\config_network.json', 'utf8'));
|
const config = JSON.parse(fs.readFileSync(path.join('services','config','config_network.json'), 'utf8'));
|
||||||
|
|
||||||
// Extraction des informations de config
|
// Extraction des informations de config
|
||||||
const { hosts: { buzzers: { IP: buzzerIPs, MQTTconfig: { mqttHost, mqttTopic } } } } = config;
|
const { hosts: { buzzers: { IP: buzzerIPs, MQTTconfig: { mqttHost, mqttTopic } } } } = config;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"services": {
|
"services": {
|
||||||
"mqttHost": "mqtt://192.168.1.30",
|
"mqttHost": "mqtt://nanomq",
|
||||||
"score": {
|
"score": {
|
||||||
"MQTTconfig": {
|
"MQTTconfig": {
|
||||||
"mqttScoreTopic": "game/score",
|
"mqttScoreTopic": "game/score",
|
||||||
@@ -14,5 +14,4 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -8,10 +8,9 @@
|
|||||||
"yellowBuzzerIP": "8.8.8.8"
|
"yellowBuzzerIP": "8.8.8.8"
|
||||||
},
|
},
|
||||||
"MQTTconfig": {
|
"MQTTconfig": {
|
||||||
"mqttHost": "mqtt://192.168.1.28",
|
"mqttHost": "mqtt://nanomq",
|
||||||
"mqttTopic": "buzzer/watcher"
|
"mqttTopic": "buzzer/watcher"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const mqtt = require('mqtt');
|
const mqtt = require('mqtt');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
// Lecture du fichier de configuration
|
// Lecture du fichier de configuration
|
||||||
const config = JSON.parse(fs.readFileSync('\services\\config\\config_game.json', 'utf8'));
|
const config = JSON.parse(fs.readFileSync(path.join('services','config','config_game.json'), 'utf8'));
|
||||||
|
|
||||||
// Extraction des informations de config
|
// Extraction des informations de config
|
||||||
const { services: { mqttHost, quizzcollector: { MQTTconfig: { mqttQuizzCollectorListTopic, mqttQuizzCollectorCmdTopic } } } } = config;
|
const { services: { mqttHost, quizzcollector: { MQTTconfig: { mqttQuizzCollectorListTopic, mqttQuizzCollectorCmdTopic } } } } = config;
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ function updateTeamTotalScore(teamColor, points) {
|
|||||||
|
|
||||||
|
|
||||||
// Lecture du fichier de configuration
|
// Lecture du fichier de configuration
|
||||||
const config = JSON.parse(fs.readFileSync('\services\\config\\config_game.json', 'utf8'));
|
const config = JSON.parse(fs.readFileSync(path.join('services','config','config_game.json'), 'utf8'));
|
||||||
|
|
||||||
// Extraction des informations de config
|
// Extraction des informations de config
|
||||||
const { services: { mqttHost, score: { MQTTconfig: { mqttScoreTopic, mqttScoreChangeTopic } } } } = config;
|
const { services: { mqttHost, score: { MQTTconfig: { mqttScoreTopic, mqttScoreChangeTopic } } } } = config;
|
||||||
|
|||||||
@@ -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 = {
|
||||||
|
|||||||
Reference in New Issue
Block a user