Create a Docker-Compose App¶
In the Configuring Git section, you should have set up git with your
auth token, meaning you can clone your Factory repositories from
https://source.foundries.io/factories/<factory>/ and begin creating new
targets for your devices to update to.
Example Apps¶
This default example shows how apps are enabled. You should read the contents of
the shellhttpd folder to see how this application has been defined, or read
the other examples to learn how you can define an app from scratch.
Clone your containers.git repo and enter it:
git clone https://source.foundries.io/factories/<factory>/containers.git cd containers.git
We initialise your
containers.gitrepository with a simple compose app example inshellhttpd.disabled/Tip
Directory names ending with
.disabledin containers.git are ignored by our CI system.
Enable the
shellhttpdexample app:mv shellhttpd.disabled shellhttpd
Add, commit and push:
git add . git commit -m "shellhttpd: enable shellhttpd app" git push
-
When changes are made to
containers.gitin your Factory sources, a new target is built by our CI system. Devices that are registered to your Factory will be able to see this target and conditionally update to it, depending on their device configuration.
Device Configuration
Now that a target is being built, we want to tell our device(s) to update to this new target. This is done using Fioctl.
Determine the device you want to configure to use
shellhttpd:fioctl devices list
your output should look like this:
NAME FACTORY OWNER TARGET STATUS APPS UP TO DATE ---- ------- ----- ------ ------ ---- ---------- foo gavin <unconfigured> raspberrypi3-64-lmp-19 OK true
Configure the device to run the
shellhttpdapp. Make sure to replace<device>with theNAMEof yours:fioctl devices config updates <device> --apps shellhttpd
This example describes how to create a docker-compose app for the Mosquitto MQTT Broker from scratch.
Clone your containers.git repo and enter it. Make sure to replace
<factory>in the example with the name of your Factory:git clone https://source.foundries.io/factories/<factory>/containers.git cd containers.git
Create a directory named
mosquittoandcdinto it. This folder name defines the name of the container image that will be pulled on your device fromhub.foundries.io:mkdir mosquitto cd mosquitto
Create a file named
Dockerfileto describe your container, with the following contents:FROM eclipse-mosquitto:latest
Create a file named
docker-compose.ymlto describe how you want this container to run, with the following contents. Make sure to replace<factory>in the example below with the name of your Factory:version: "3.2" services: mosquitto: restart: always image: hub.foundries.io/<factory>/mosquitto:latest ports: - "1883:1883"
Add, commit and push:
git add . git commit -m "mosquitto: create mosquitto container" git push
-
When changes are made to
containers.gitin your Factory sources, a new target is built by our CI system. Devices that are registered to your Factory will be able to see this target and conditionally update to it, depending on their device configuration.
Device Configuration
Now that a target is being built, we want to tell our device(s) to update to this new target. This is done using Fioctl.
Determine the device you want to configure to use
mosquitto:fioctl devices list
your output should look like this:
NAME FACTORY OWNER TARGET STATUS APPS UP TO DATE ---- ------- ----- ------ ------ ---- ---------- foo gavin <unconfigured> raspberrypi3-64-lmp-19 OK true
Configure the device to run the
mosquittoapp. Make sure to replace<device>with theNAMEof yours:fioctl devices config updates <device> --apps mosquitto
About Targets¶
You can see the available targets your Factory has produced:
fioctl targets list
CLI Output:
VERSION TAGS APPS HARDWARE IDs
------- ---- ---- ------------
2 devel raspberrypi3-64
3 master raspberrypi3-64
4 master shellhttpd raspberrypi3-64
details about target can be printed by passing its version number to the
show subcommand:
fioctl targets show 4
CLI Output:
Tags: master
CI: https://ci.foundries.io/projects/gavin/lmp/builds/4/
Source:
https://source.foundries.io/factories/gavin/lmp-manifest.git/commit/?id=2aaebc4b16c1027c9aae167d6178a8f248027a73
https://source.foundries.io/factories/gavin/meta-subscriber-overrides.git/commit/?id=19cbbe7b890eafed4d88e1fb13d2d61ecef8f3e5
https://source.foundries.io/factories/gavin/containers.git/commit/?id=6a2ef8d1dbab0db634c52950ae4a7c18494021b2
TARGET NAME OSTREE HASH - SHA256
----------- --------------------
raspberrypi3-64-lmp-4 1b0df36794efc32f1c569c8d61f115b04c4d51caa2fa99c17ec85384ae06518d
DOCKER APP VERSION
---------- -------
shellhttpd shellhttpd.dockerapp-4
Completion¶
Now that you’re done, you might want to read Tutorials to see some examples of the things that can be done with your Factory. Additionally, you can read the Reference Manual to learn more about the architecture of FoundriesFactory and the Linux microPlatform.