# Build Linux IoT and Edge archive Apps

Ionoid.io IoT and Edge Linux apps are archive files that bundle the application, libraries, files and other dependencies. Using some of Linux Containers Technology to implement file system isolation, devices are able to run multiple applications isolated from one another.

This section describes how to build archive Linux apps that can run on any Linux device. To be able to deploy the archive with Ionoid.io and run it on devices, the archive must then include the app YAML file inside the root directory / of the archive.

# Linux Containers Concept

Linux containers are a modern technology that packages the application and all its dependencies so the applications can run on any Linux system. Ionoid.io supports Linux containers by using classic archive files format that were first released in late of 1979; this is motivated by the fact that IoT and Edge devices should have a long life time, and by using archive files for application packages, Ionoid.io ensures archive apps will continue to work in the future, as all the necessary tools to process them are standard open source tools.

At run-time when the archive file is deployed on devices, the app YAML file that is on the root directory / of the archive will be used to define how the application will run.

Ionoid.io makes minimal use of Linux containers technologies by just using file system isolation, where each deployed application will have its own correspondig directory, see previous chapter IoT Apps.

# The mkiot (make IoT) Tool

To generate the app archive we use mkiot, which uses debootstrap and other tools to build an app archive.

The mkiot tool allows us to:

  1. Install a Linux distribution file system that will be used as a build image for the application,

  2. Build the application,

  3. Copy application files and other dependencies into image,

  4. Copy the app.yaml file into the image,

  5. Generate an artifact from the image.

Please follow mkiot installation documentation and install it on your Linux working station.

# Linux IoT Build Environments

This section describes how to generate IoT and Edge apps build environments.

Building an IoT app can somehow be challening, usually we suggest to start with a full build enviroment, then try to optimize later using mkiot multi-stage builds to reduce the final image size.

Ionoid.io supports Debian and Alpine Linux images, more will be added soon.

Assuming mkiot is installed and ready, let's start building our environments and apps.

# Debian Environment

From the mkiot examples we use the Debian minimal buildspec.yaml:

sudo mkiot build examples/debian/buildspec.yaml

This will generate an artifact in tar archive format at:

./output/artifacts/debian-buster_armhf_2020-06-11.tar

If you want to generate a Debian environment with development tools and packages, you can use the Debian devtools buildspec.yaml example and edit it to add more commands or packages to be installed in commands:

sudo mkiot build examples/devtools/debian/buster/buildspec-devtools-armhf.yaml

This will generate an artifact in tar archive format at:

./output/artifacts/devtools_debian-buster_armhf.tar

# Alpine Environment

Under development, will be added soon.

# Node.js Apps

Node.js is an open source, cross-platform, JavaScript runtime environment that executes JavaScript code outside a web browser. See Wikipedia for more details.

We can build a Node.js environment using one of the supported distributions as a base image for the file system.

# Node.js Debian Based Image

The following examples demonstrate how to use mkiot to build a Node.js environment that is targeted to ARMv7 architectures, as Node.js only supports ARMv7 and above, for further documentation please see the Node.js Download page.

To have a Node.js environment from upstream Node.js package on a minimal Debian file system, run mkiot with the following Node.js minimal Debian buildspec.yaml:

sudo mkiot build examples/node.js/debian/buster/buildspec-node.js-minimal-debian-armhf.yaml

To have Node.js installed as a binary on a Debian file system, with extra packages like devtools , build essential or yarn, run mkiot build with the following Node.js devtools Debian buildspec.yaml:

sudo mkiot build examples/node.js/14/buster/buildspec-node.js-devtools-debian-armv7l.yaml

Produced artifacts will be inside ./output/artifacts/ in the current working directory.

To change the enviroment in order to update which packages or denpendecies should be installed or removed, please copy and edit the buildspec.yaml files. Make sure to copy in script file that is used during build to the right location too, according to mkiot script command.

# Node.js Alpine Based Image

Will be added soon.

# Node.js Apps Examples

# Node.js Debian based apps

  • Hello-world app can be built using:

       files:
           # copy app.yaml to root artifact /app.yaml
           - app.yaml /app.yaml
    
           # copy my application
           - hello-world.js  /usr/bin/hello-world.js
    
    • Then build this example from mkiot source:
       cd examples/apps/hello-world/node.js/
       sudo mkiot build debian/buster/hello-world_node-14.0_minimal_debian_armhf.yaml
    
    • This will generate the final artifact inside ./output/artifact/.
  • Node-RED - Low-code programming for event-driven applications

    • Node-RED is a programming tool for wiring together hardware devices, APIs and online services in new and interesting ways.

    • Node-RED artifacts can be built using the following build Node-RED documentation.

  • More applications will be added soon.

# Node.js Alpine based apps

  • More applications will be added soon.

# Python Apps

Python is an interpreted, high-level, general-purpose programming language. See Wikipedia for more details.

# Python Debian Based Image

The following examples demonstrate how to use mkiot to build a Python environment that is targeted to ARM architectures.

To have a python2 environment on minimal Debian, run mkiot build with the Python2 on minimal Debian buildspec.yaml file:

sudo mkiot build examples/python/debian/buster/buildspec-python2-minimal-debian-armhf.yaml

To have a python3 environment on minimal Debian, run mkiot build with the Python3 on minimal Debian buildspec.yaml file:

sudo mkiot build examples/python/debian/buster/buildspec-python3-minimal-debian-armhf.yaml

To have a python3 environment on Debian with some development packages, run mkiot build with the Python3 on devtools Debian buildspec.yaml file:

sudo mkiot build examples/python/debian/buster/buildspec-python3-devtools-debian-armhf.yaml

# Python Alpine Based Image

Will be added soon.

# Python Apps Examples

# Python Debian based app

  • Hello-world app can be built using:

       files:
           # copy app.yaml to root artifact /app.yaml
           - app.yaml /app.yaml
    
           # copy my application
           - hello-world.py  /usr/bin/hello-world.py
    
    • Then build this example from mkiot source:
       cd examples/apps/hello-world/python/
       sudo mkiot build debian/buster/hello-world_python3_minimal_debian_armhf.yaml
    
    • This will generate the final artifact inside ./output/artifact/.
  • Tensor flow app

# Python Alpine based app

Will be added soon.

Have Questions?

We're always happy to help with IoT projects or other questions you might have! Check our documentation, contact our support team at support@ionoid.io, or our sales team sales@opendevices.io. You can also ask questions on our forums or open an issue on Github.