# Production Setup {#web-production}

## Setting up VILLASweb for production

For development setup instructions see @ref web-development.
The production setup is based on docker. 
Clone the [frontend](https://git.rwth-aachen.de/acs/public/villas/web) and [backend](https://git.rwth-aachen.de/acs/public/villas/web-backend-go) repositories on your computer and build the Docker images for both:

### Frontend
 - `cd VILLASweb`
 - `docker build -t villasweb-frontend .`
 
### Backend
 - `cd ..\VILLASweb-backend-go`
 - `docker build -t villasweb-backend .`

### WIP Docker compose and/or Kubernetes
Run the production docker-compose file:
 - `docker-compose -f docker-compose-production.yml up -d`


## Configure VILLASnode to get data into VILLASweb

### Install VILLASnode

See: @ref node-installation

### Create a VILLASnode demo data source

1. Create a new empty configuration file with the following contents and save it as `webdemo.conf`:

> WIP this example configuration requires revision!
```
nodes = {
    sine = {
        type = "signal"
        
        signal = "mixed"
        values = 5
        rate = 25
        frequency = 5
    }
 
    web = {
        type = "websocket"

        destinations = [
                "TODO"
        ]
    }
 }
 
 paths = (
    {
        in = "sine"
        out = "web"
    }
 )
```

The node `sine` is a software signal generator for 5 signals.
The node `web` is the websocket interface to stream the data generated by the `sine` node to the browser.

> Note: If you do not want to use your local system as the destination for the websocket node,
>change the option `destinations` of the `web` node to the destination of your production environment, for example `https://my.production.environment/ws/webdemo`.

### Start the VILLASnode gateway

Run the following command on your system:

```bash
villas node webdemo.conf
```
> Note: Change the path to the configuration file accordingly. The `villas` command will only work if VILLASnode is installed on your system.

### Visualize real-time data in VILLASweb Dashboards
1. Use the VILLASweb frontend to create a new infrastructure component for the VILLASnode gateway from above (Admin user required).
2. Set the `host` parameter of the component to the target you used as the `web.destinations` parameter in the configuration from above.
3. Create a new scenario in VILLASweb and within that scenario create a new component configuration that uses the infrastructure component you created under 2.
4. WIP: Use the signal auto-configure function to retrieve the signal configuration of the VILLASnode automatically. 
5. Create a new dashboard with widgets of your choice and link these widgets to the signals received from the infrastructure component.
6. Enjoy what you see.