Adapting Shellhttpd#
Edit shellhttpd
back to its original state.
Tip
If you do not have the shellhttpd
application, complete Creating Your First Target.
Open a terminal on your host machine and go into your containers
repo folder.
$ cd containers/
Edit httpd.sh
:
$ vi 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 Dockerfile
:
$ vi shellhttpd/Dockerfile
FROM alpine
COPY httpd.sh /usr/local/bin/
CMD ["/usr/local/bin/httpd.sh"]
Edit docker-compose.yml
:
$ vi shellhttpd/docker-compose.yml
version: '3.2'
services:
httpd:
image: hub.foundries.io/<factory>/shellhttpd:latest
restart: always
ports:
- 8080:${PORT-8080}
environment:
MSG: "${MSG-Hello world}"
Commit and push all changes:
$ git status
$ git add shellhttpd/docker-compose.yml
$ git add shellhttpd/httpd.sh
$ git add shellhttpd/Dockerfile
$ git commit -m "Changes for adapting shellhttpd tutorial"
$ git push
Wait for your build to finish by checking the latest Target on the Devices tab.
Use fioctl
to configure your device to run just the shellhttpd
application:
$ fioctl devices config updates --apps shellhttpd <device-name>
Changing apps from: [] -> [shellhttpd]
Changing packagemanager to ostree+compose_apps
In a few minutes your device should receive an update.
Test the container on your device:
device:~$ wget -qO- 127.0.0.1:8080
Hello world
Check the Target version list with fioctl
$ fioctl targets list
VERSION TAGS APPS HARDWARE IDs
------- ---- ---- ------------
2 devel raspberrypi4-64
3 main raspberrypi4-64
4 devel shellhttpd raspberrypi4-64
5 devel shellhttpd raspberrypi4-64
6 devel shellhttpd raspberrypi4-64
7 devel shellhttpd raspberrypi4-64
8 devel shellhttpd-mqtt,mosquitto,shellhttpd,flask-mqtt-nginx raspberrypi4-64
9 devel mosquitto,shellhttpd,flask-mqtt-nginx,shellhttpd-mqtt raspberrypi4-64
10 devel mosquitto,shellhttpd,flask-mqtt-nginx,shellhttpd-mqtt raspberrypi4-64
Check what Target your device is running:
$ fioctl device list
NAME FACTORY TARGET STATUS APPS UP-TO-DATE
---- ------- ------ ------ ---- ----------
<device-name> <factory> raspberrypi4-64-lmp-10 OK flask-mqtt-nginx,mosquitto,shellhttpd-mqtt true
Whenever you push changes to the devel
branch, the CI will build and generate a new Target tagged with devel
.
As a result, devices following devel
will update to the latest Target.