diff --git a/VContainers/VApp/config/config.js b/VContainers/VApp/config/config_dev.js similarity index 64% rename from VContainers/VApp/config/config.js rename to VContainers/VApp/config/config_dev.js index e90c2370..d8cb3259 100644 --- a/VContainers/VApp/config/config.js +++ b/VContainers/VApp/config/config_dev.js @@ -1,7 +1,6 @@ window.APP_CONFIG = { // URL du broker MQTT (WebSockets) - // En dev local avec le setup VContainers, utiliser 'ws://localhost:9001' - // En prod, utiliser l'IP du serveur, ex: 'ws://192.168.73.252:9001' + // Configuration DEV : localhost mqttBrokerUrl: 'ws://localhost:9001', // IPs des buzzers diff --git a/VContainers/VApp/config/config_prod.js b/VContainers/VApp/config/config_prod.js new file mode 100644 index 00000000..a1824791 --- /dev/null +++ b/VContainers/VApp/config/config_prod.js @@ -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' +}; diff --git a/VContainers/run.sh b/VContainers/run_dev.sh similarity index 83% rename from VContainers/run.sh rename to VContainers/run_dev.sh index 621c03e1..55a29882 100755 --- a/VContainers/run.sh +++ b/VContainers/run_dev.sh @@ -24,10 +24,10 @@ 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..." +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.js:/usr/share/nginx/html/config.js:Z \ + -v ./VContainers/VApp/config/config_dev.js:/usr/share/nginx/html/config.js:Z \ vapp:latest -echo "All containers started on network $NETWORK_NAME." +echo "All containers started on network $NETWORK_NAME with DEV configuration." diff --git a/VContainers/run_prod.sh b/VContainers/run_prod.sh new file mode 100755 index 00000000..a4376e83 --- /dev/null +++ b/VContainers/run_prod.sh @@ -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."