diff --git a/Dockerfile b/Dockerfile index b014976..c88afc6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/VILLASweb-backend b/VILLASweb-backend deleted file mode 160000 index 8184b91..0000000 --- a/VILLASweb-backend +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 8184b91f013f25887a129fd95354da3cc5796244 diff --git a/docker-compose.yml b/docker-compose.yml index fdf2c4a..9bc0d4a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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" \ No newline at end of file + - "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: \ No newline at end of file diff --git a/nginx/villas.conf b/etc/nginx/villas.conf similarity index 79% rename from nginx/villas.conf rename to etc/nginx/villas.conf index 7fd9ee9..58872f4 100644 --- a/nginx/villas.conf +++ b/etc/nginx/villas.conf @@ -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 / { diff --git a/etc/node/websocket.conf b/etc/node/websocket.conf new file mode 100644 index 0000000..3a16599 --- /dev/null +++ b/etc/node/websocket.conf @@ -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 + * @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 . + *********************************************************************************/ + +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 } +); diff --git a/nginx/Dockerfile b/nginx/Dockerfile deleted file mode 100644 index 6902568..0000000 --- a/nginx/Dockerfile +++ /dev/null @@ -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