Adapting ShellhttpdΒΆ

Edit the shellhttpd application back to its original state.

Tip

In case you do not have the shellhttpd application. Complete the tutorial: Creating your first Target

Open a new terminal in your host machine and find the container folder used in the previous tutorial.

cd containers/

Edit the file httpd.sh according to the example below:

gedit shellhttpd/httpd.sh

shellhttpd/httpd.sh:

#!/bin/sh -e

PORT="${PORT-8080}"
MSG="${MSG-OK}"

RESPONSE="HTTP/1.1 200 OK\r\n\r\n${MSG}\r\n"

while true; do
        echo -en "$RESPONSE" | nc -l -p "${PORT}" || true
        echo "= $(date) ============================="
done

Edit the file Dockerfile according to the example below:

gedit shellhttpd/Dockerfile

shellhttpd/Dockerfile:

FROM alpine

COPY httpd.sh /usr/local/bin/

CMD ["/usr/local/bin/httpd.sh"]

Edit the file docker-compose.yml according to the example below:

gedit shellhttpd/docker-compose.yml

shellhttpd/docker-compose.yml:

version: '3.2'

services:
  httpd:
    image: hub.foundries.io/cavel/shellhttpd:latest
    restart: always
    ports:
      - 8080:${PORT-8080}
    environment:
      MSG: "Tag devel, test:01"

Note that MSG is defined with This is the TEST 01.

Commit and push all changes done in the containers folder:

git status
git add shellhttpd/docker-compose.yml
git add shellhttpd/httpd.sh
git add shellhttpd/Dockerfile
git commit -m "This is the TEST 02"
git push

Wait for your build to finish by checking the latest Target on the Devices tab in your Factory.

Use fioctl to configure your device to run just the shellhttpd application:

fioctl devices config updates --apps shellhttpd <device-name>

Example Output:

Changing apps from: [] -> [shellhttpd]
Changing packagemanager to ostree+compose_apps

In a maximum of 2 minutes, your device should receive an update.

On your device, test the container again by running the following command:

wget -qO- 127.0.0.1:8080

Example Output:

This is the TEST 01

Check again the Target version list with fioctl

fioctl targets list

Example Output:

VERSION  TAGS    APPS                                                   HARDWARE IDs
-------  ----    ----                                                   ------------
2        devel                                                          raspberrypi3-64
3        master                                                         raspberrypi3-64
4        devel   shellhttpd                                             raspberrypi3-64
5        devel   shellhttpd                                             raspberrypi3-64
6        devel   shellhttpd                                             raspberrypi3-64
7        devel   shellhttpd                                             raspberrypi3-64
8        devel   shellhttpd-mqtt,mosquitto,shellhttpd,flask-mqtt-nginx  raspberrypi3-64
9        devel   mosquitto,shellhttpd,flask-mqtt-nginx,shellhttpd-mqtt  raspberrypi3-64
10       devel   mosquitto,shellhttpd,flask-mqtt-nginx,shellhttpd-mqtt  raspberrypi3-64

Check what Target your device is running:

fioctl device list

Example Output:

NAME           FACTORY     TARGET                 STATUS  APPS                                        UP-TO-DATE
----           -------     ------                 ------  ----                                        ----------
<device-name>  <factory>   raspberrypi3-64-lmp-10 OK      flask-mqtt-nginx,mosquitto,shellhttpd-mqtt  true

Whenever you change the devel branch, FoundriesFactory CI will build and generate a new Target tagged with devel. As a result, devices following devel will update to the latest Target.