# Dockerized purple

## Overview
This directory contains a dockerized version of purple which runs a limited set of the purple services.
It contains mocks for the following services:
- DisplayBridge 
  - Statically returns an array of displays i.o. querying the system with xrandr
- AudioBridge
  - Statically returns an array of audio sinks, sources and profiles i.o. listening to pulseaudio
- CameraBridge
  - Statically returns an array of cameras i.o. querying os
- mdns
  - Creates an advertisement which works for local docker containers. This makes it impossible for now to pair dockers besides your own machine.

The dockerized_purple.patch also contains required patches to run as a docker
- replaces `sudo dmidecode` with hardcoded string
- electron should run in a window i.o. kiosk mode
- imports mocks where necessary

The main use cases for this docker are:
- checking/debugging basic purple connectivity
- checking/debugging electron windows

## Build

```shell script
docker build -t lavender --network=host --build-arg NPM_CONFIG_ALWAYS_AUTH=$NPM_CONFIG_ALWAYS_AUTH --build-arg NPM_CONFIG_REGISTRY=$NPM_CONFIG_REGISTRY --build-arg NPM_CONFIG__AUTH=$NPM_CONFIG__AUTH -f docker/Dockerfile .
```

## Run

When running `docker-compose` it will create and mount `~/purple_configs` directory.


```shell script
xhost local:root
docker-compose -f docker/docker-compose.yml up
```

if you want to run only specific device

```shell script
docker-compose -f docker/docker-compose.yml up purple_tile
```

## Pairing to cloud
Run the custom pairingtool (playground/dockerized-purple branch) to pair the devices to your cloud

## For Ubuntu 19 users

Edit /etc/gdm3/custom.conf and add the code below to ensure x11 will listen for incoming TCP connections
```shell script
[security]
DisallowTCP=false
```

Add the following line to environment for each purple instance in the docker-compose file
```shell script
- DISPLAY=172.17.0.1:0
```

On first run:
```shell script
xhost +
docker-compose -f docker/docker-compose.yml up
```

xhost + is not very secure so only do this to find the correct IP address, kill the process and run 

```shell script
xhost -
```

Check the IP address that is assigned to each purple instance (eg 172.18.0.2, 172.18.0.3, 172.18.0.4) so on the next run you can do:

```shell script
xhost 172.18.0.2
xhost 172.18.0.3
xhost 172.18.0.4
docker-compose -f docker/docker-compose.yml up
```
