Commit 38863ee1 authored by Steffen Vogel's avatar Steffen Vogel 🎅🏼

start VILLASnode services and use frontend to proxy WebSocket endpoint

parent 6af5fa43
FROM node:latest FROM nginx:stable-alpine
RUN mkdir /react # Copy frontend files and make them accesible to nginx
RUN mkdir /result RUN mkdir /www
COPY build /www
RUN chown nginx:nginx -R /www
RUN chmod -R 0755 /www
VOLUME /result # Copy nginx configuration
COPY etc/nginx/villas.conf /etc/nginx/conf.d/default.conf
WORKDIR /react
CMD npm install && npm run build && cp -R /react/build/* /result/
VILLASweb-backend @ 8184b91f
Subproject commit 8184b91f013f25887a129fd95354da3cc5796244
...@@ -4,31 +4,35 @@ volumes: ...@@ -4,31 +4,35 @@ volumes:
database: database:
driver: local driver: local
networks:
villas:
services: services:
# The VILLASweb frontend
frontend: frontend:
build: build:
context: . context: .
dockerfile: nginx/Dockerfile
links:
- backend
environment: environment:
- REACT_APP_HTTP_PROXY - REACT_APP_HTTP_PROXY
ports: ports:
- "80:80" - "80:80"
- "443:443" - "443:443"
restart: always restart: always
networks:
villas:
# The VILLASweb backend
backend: backend:
build: backend build: backend
links:
- database
- broker
environment: environment:
- NODE_ENV=production - NODE_ENV=production
ports: ports:
- "4000:4000" - "4000:4000"
restart: always restart: always
networks:
villas:
# The MongoDB database for the VILLASweb backend
database: database:
image: mongo:latest image: mongo:latest
user: mongodb user: mongodb
...@@ -36,7 +40,10 @@ services: ...@@ -36,7 +40,10 @@ services:
- database:/data/db - database:/data/db
restart: always restart: always
user: mongodb user: mongodb
networks:
villas:
# AMQP broker for VILLAScontroller
broker: broker:
image: rabbitmq:management image: rabbitmq:management
environment: environment:
...@@ -44,4 +51,32 @@ services: ...@@ -44,4 +51,32 @@ services:
- RABBITMQ_DEFAULT_PASS=s3c0sim4! - RABBITMQ_DEFAULT_PASS=s3c0sim4!
ports: ports:
- "8080:15672" - "8080:15672"
- "5672:5672" - "5672:5672"
\ No newline at end of file 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:
\ No newline at end of file
...@@ -13,6 +13,13 @@ server { ...@@ -13,6 +13,13 @@ server {
proxy_pass http://backend:4000/; 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 # frontend location
location / { location / {
......
/** 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 }
);
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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment