1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/web/ synced 2025-03-09 00:00:01 +01:00

start VILLASnode services and use frontend to proxy WebSocket endpoint

This commit is contained in:
Steffen Vogel 2017-06-28 02:42:43 +02:00
parent 6af5fa4346
commit 38863ee166
6 changed files with 114 additions and 26 deletions

View file

@ -1,10 +1,10 @@
FROM node:latest
FROM nginx:stable-alpine
RUN mkdir /react
RUN mkdir /result
# Copy frontend files and make them accesible to nginx
RUN mkdir /www
COPY build /www
RUN chown nginx:nginx -R /www
RUN chmod -R 0755 /www
VOLUME /result
WORKDIR /react
CMD npm install && npm run build && cp -R /react/build/* /result/
# Copy nginx configuration
COPY etc/nginx/villas.conf /etc/nginx/conf.d/default.conf

@ -1 +0,0 @@
Subproject commit 8184b91f013f25887a129fd95354da3cc5796244

View file

@ -4,31 +4,35 @@ volumes:
database:
driver: local
networks:
villas:
services:
# The VILLASweb frontend
frontend:
build:
context: .
dockerfile: nginx/Dockerfile
links:
- backend
environment:
- REACT_APP_HTTP_PROXY
ports:
- "80:80"
- "443:443"
restart: always
networks:
villas:
# The VILLASweb backend
backend:
build: backend
links:
- database
- broker
environment:
- NODE_ENV=production
ports:
- "4000:4000"
restart: always
networks:
villas:
# The MongoDB database for the VILLASweb backend
database:
image: mongo:latest
user: mongodb
@ -36,7 +40,10 @@ services:
- database:/data/db
restart: always
user: mongodb
networks:
villas:
# AMQP broker for VILLAScontroller
broker:
image: rabbitmq:management
environment:
@ -44,4 +51,32 @@ services:
- RABBITMQ_DEFAULT_PASS=s3c0sim4!
ports:
- "8080:15672"
- "5672:5672"
- "5672:5672"
networks:
villas:
# VILLASnode, the gateway between UDP and WebSocket traffic
node:
image: villas/node:latest
privileged: true
command: [ "node", "/etc/villas/node/websocket.conf" ]
expose:
- "12000/udp"
ports:
- "8081:80/tcp"
volumes:
- "./etc/node/:/etc/villas/node/"
networks:
villas:
# Generate random data and send it via UDP to the 'node' service
signal:
image: villas/node:latest
privileged: true
entrypoint: bash
command: [ "-c", "villas signal mixed -v4 | villas pipe -x /etc/villas/node/websocket.conf udp_1"]
volumes:
- "./etc/node/:/etc/villas/node/"
stop_signal: SIGINT
networks:
villas:

View file

@ -13,6 +13,13 @@ server {
proxy_pass http://backend:4000/;
}
location /ws/ {
proxy_pass http://node/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
# frontend location
location / {

57
etc/node/websocket.conf Normal file
View file

@ -0,0 +1,57 @@
/** Example configuration file for VILLASnode.
*
* The syntax of this file is similar to JSON.
* A detailed description of the format can be found here:
* http://www.hyperrealm.com/libconfig/libconfig_manual.html#Configuration-Files
*
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
* @copyright 2017, Institute for Automation of Complex Power Systems, EONERC
* @license GNU General Public License (version 3)
*
* VILLASnode
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************************/
nodes = {
ws_1 = {
type = "websocket",
description = "Demo Channel",
#vectorize = 10,
source = {
simulator = "OP5600",
location = "ACS lab"
},
series = (
{ label = "Random walk", unit = "V" },
{ label = "Sine", unit = "A" },
{ label = "Rect", unit = "Var"},
{ label = "Ramp", unit = "°C" }
)
},
udp_1 = {
type = "socket",
layer = "udp",
remote = "signal:12001"
local = "node:12000"
},
};
############ List of paths ############
paths = (
{ in = "udp_1", out = "ws_1", reverse = true }
);

View file

@ -1,10 +0,0 @@
FROM nginx:stable-alpine
# Copy frontend files and make them accesible to nginx
RUN mkdir /www
COPY build /www
RUN chown nginx:nginx -R /www
RUN chmod -R 0755 /www
# Copy nginx configuration
COPY nginx/villas.conf /etc/nginx/conf.d/default.conf