mozilla-iot-gateway-container

This provides the container description for the mozilla-iot-gateway

Requires

The following needs to be installed on your development system: - podman

Creation of image

To create the mozilla-iot-gateway-container image use

podman build -f Dockerfile -t mozilla-iot-gateway .

In order for this to work you have to be in the directory of the dockerfile.

Run image

for testing purposes

To allow mounting of a directory, .e.g. /mnt/mozilla-iot, from an running container we have to set the selinux permission in such a way that this is allowed. This is done using the following command

chcon -Rt svirt_sandbox_file_t /mnt/mozilla-iot

With this command we can mount the folder /mnt/mozilla-iot in the container. If we don't do this we get a persmission denied error.

Use the following command to run the image for testing purposes:

podman run --rm -it -p 8080:8080 -v /mnt/mozilla-iot:/root/.mozilla-iot/:rw mozilla-iot-gateway /bin/bash

To test if everything works open your browser of choice and go to the URL: http:localhost:8080. Note that the path to the volume needs to provides in an absolute way, both inside and outside of the container.

The log-files of the mozilla-iot-gateway can be found outside of the container in the persistent volumn /mnt/mozilla-iot.

Run image for production

Use the following command to run the image and access the gateway from outside

podman run -d -p 8080:8080 -v /mnt/mozilla-iot:/root/.mozilla-iot/:rw mozilla-iot-gateway

This will provide you with an container <ID> which you can use with the following command to attach to the container

podman exec -t -i <ID> /bin/bash

To assign a name to the running container just modify the above command to

podman run -d -p 8080:8080 -v /mozilla-iot:/root/.mozilla-iot/:rw --name m-iot-gw1 mozilla-iot-gateway

Microdnf approach for smaller container images

For more information see: https://fedoramagazine.org/building-smaller-container-images/

The image can be build using

podman build -f DockerfileMicroDnf  -t mozilla-iot-gateway-micro .

and run using

podman run -d --rm -p 8080:8080 -v /mozilla-iot:/root/.mozilla-iot/:rw --name m-iot-gw-micro mozilla-iot-gateway-micro

Accessing the running container from a different host

The general purpose of this image is to run it on an IOT device like an Rasberry Pi (RP3b+ and higher) and access it from outside. To do this you need to open the firewall on the device. This needs to be done using the following commands:

firewall-cmd --add-port=4443/tcp --permanent

firewall-cmd --add-port=8080/tcp --permanent

firewall-cmd --add-port=5353/udp --permanent

firewall-cmd --reload

Now you should be able to connect to the mozilla-iot-gateway under the <host-url>:8080, where host-url is the URL of the IOT device.