<commit_before># Container Application Development with Go

## MQTT Sample Application

### Introduction
This demo shows how to setup a MQTT broker service and a container 
application written in Go. The demo uses the [Mosquitto](http://www.mosquitto.org/ "Mosquitto")
service on an Ubuntu linux server and the Paho Go Client for the MQTT connection.

Consider following MQTT connection settings:
- Topic: first/demo
- Username: joe
- Password: <PASSWORD> 

### Setup container with MQTT broker service

#### 1. Install SDK
Follow the instructions in the [Install guide](https://github.com/insys-icom/M3_Container/blob/master/doc/Install_Virtualbox.md) to setup the SDK.

#### 2. Create container with MQTT broker service
To create a container with a mosquitto MQTT broker service follow these steps:
##### &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2.1 Start virtualbox with your SDK
##### &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2.2 Change to the root directory of the git repository (most likely "~/M3_Container") 
##### &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2.3 Execute the following command:
<pre>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$ <b>./scripts/create_container_mosquitto_mqtt_broker.sh</b>
</pre>

#### 3. Import container
Now startup your MRX device and login to the webinterface. 
Go to "/Administration/Container", click the choose file button and select the created container (see ~/M3_Container/images/ in your git repository).
After that configure Bridge to Net and IP address of the container.

#### 4. Configure MQTT Broker service
Now open a new tab and type in the IP address of the MQTT broker container.
The overview page shows you how to configure the service.

### Setup the MQTT broker service
Start an Ubuntu 14.04 instance and setup the Mosquitto MQTT service as described below. This demonstration uses a [Digital Ocean](https://www.digitalocean.com/ "Digital Ocean") droplet.

Alternatively get the [demo MQTT broker container image (Todo: fix link)](https://www.insys-icom.de/smartbox) and install it in another container instance.

#### 1. Create user "mosquitto"
The Mosquitto process should run as a normal user and not as root.
<pre>
$ <b>adduser mosquitto</b>
</pre>

#### 2. Install Mosquitto
Update the Ubuntu repositories and install Mosquitto dependencies.
<pre><commit_msg>fixed format of list<commit_after># Container Application Development with Go

## MQTT Sample Application

### Introduction
This demo shows how to setup a MQTT broker service and a container 
application written in Go. The demo uses the [Mosquitto](http://www.mosquitto.org/ "Mosquitto")
service on an Ubuntu linux server and the Paho Go Client for the MQTT connection.

Consider following MQTT connection settings:
- Topic: first/demo
- Username: joe
- Password: <PASSWORD> 

### Setup container with MQTT broker service

#### 1. Install SDK
Follow the instructions in the [Install guide](https://github.com/insys-icom/M3_Container/blob/master/doc/Install_Virtualbox.md "Install Virtualbox") to setup the SDK.

#### 2. Create container with MQTT broker service
To create a container with a mosquitto MQTT broker service follow these steps:
#####    * Start virtualbox with your SDK
#####    * Change to the root directory of the git repository (most likely "~/M3_Container") 
<pre>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>cd ~/M3_Container</b>
</pre>
#####    * Execute the following command:
<pre>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$ <b>./scripts/create_container_mosquitto_mqtt_broker.sh</b>
</pre>

#### 3. Import container
Now startup your MRX device and login to the webinterface.<br> 
Go to "/Administration/Container", click the choose file button and select the created container (see ~/M3_Container/images/ in your git repository).<br>
After that configure "Bridge to Net" and "IP address" of the container.

#### 4. Configure MQTT Broker service
Now open a new tab and type in the IP address of the MQTT broker container.
The overview page shows you how to configure the service.

### Setup the MQTT broker service
Start an Ubuntu 14.04 instance and setup the Mosquitto MQTT service as described below. This demonstration uses a [Digital Ocean](https://www.digitalocean.com/ "Digital Ocean") droplet.

Alternatively get the [demo MQTT broker container image (Todo: fix link)](https://www.insys-icom.de/smartbox) and install it in another container instance.

#### 1. Create user "mosquitto"
The Mosquitto process should run as a normal user and not as root.
<pre>
$ <b>adduser mosquitto</b>
</pre>

#### 2. Install Mosquitto
Update the Ubuntu repositories and install Mosquitto dependencies.
<pre>
{'fraction_non_alphanumeric': 0.10102777170347693, 'fraction_numerical': 0.007216269407391209, 'mean_word_length': 4.856594110115237, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 6, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1421622', 'n_tokens_mistral': 1392, 'n_tokens_neox': 1287, 'n_words': 567}