Update shellhttpd Application

The previous section, Dynamic Configuration File, shows how to send configuration files using fioctl. The section also shows where the file is located on the device: /var/run/secrets/shellhttpd.conf

The shellhttpd application is not using this file yet.

This section shows how to modify the docker-compose.yml file so that the application will use the host machine’s /var/run/secrets/shellhttpd.conf file instead of a configuration file built into the container.

Let’s start by changing the Dockerfile. Remove the addition of the shellhttpd.conf file to simplify your application:

gedit shellhttpd/Dockerfile

shellhttpd/Dockerfile:

FROM alpine

COPY httpd.sh /usr/local/bin/

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

Edit docker-compose.yml and change the volumes stanza to share the /var/run/secrets folder.

gedit shellhttpd/docker-compose.yml

shellhttpd/docker-compose.yml:

version: '3.2'

services:
  httpd:
    image: hub.foundries.io/<factory>/shellhttpd:latest
#    image: shellhttpd:1.0
    restart: always
    volumes:
      - /var/run/secrets:/home/shellhttpd/
    ports:
      - 8080:${PORT-8080}
    environment:
      MSG: "${MSG-Hello world}"

Check your changes, add, commit and push to the server:

git status
git add shellhttpd/Dockerfile
git add shellhttpd/docker-compose.yml
git commit -m "Updating shared folder path"
git push

Make sure you received your update by checking the latest Target on the Devices tab in your Factory.

Once you receive the update, the docker log should show the new message configured with fioctl in the previous section:

docker logs -f shellhttpd_httpd_1

Example Output:

PORT=8080
MSG=Hello from fioctl

If you test the application with curl, it will also display the new message:

curl <device IP>:8080

Example Output:

Hello from fioctl

Let’s repeat the fioctl config command used in the previous section, and confirm that everything is working.

Update the configuration file using fioctl in your host machine:

fioctl devices config set <device-name> shellhttpd.conf="MSG=\"New config file updated over-the-air\""

Wait and test your application again:

curl <device IP>:8080

Example Output:

New config file updated over-the-air