1. Home
  2. Getting Started
  3. Tutorials
  4. Barbara onboarding Tutorial – Chapter 4: Deploying custom apps

Barbara onboarding Tutorial – Chapter 4: Deploying custom apps

We assume you have have already deployed successfully the tests apps included in your starter kit following the previous sections. In this section you will learn how to deploy your own Docker applications. We also asume you are already familiar with Docker containers, and specifically with creating Docker applications using Docker compose files

Before you start deploying your own apps, ff your device is constrained in resources, please consider removing all or some of the example apps before deploying your own Docker containers. In order to remove an app, just delete the App Card by clicking on the little “X” next to the app’s name.

  1. How to package a docker for deployment

Barbara Edge applications need to be packaged in zip files for being deployed to Edge Devices via Barbara Panel. The zip directory structure shall include at least a docker-compose.yamlfile in the root, but it is also highly recommended to include at least a ./persist folder 

Where:

  • docker-compose.yaml is the Docker Compose file, the mail file that allows the docker daemon understand which services must be used as well as other details related with their orchestration (check more info in https://docs.docker.com/compose/ ….
  • persist is the folder that contains all the content that you want your app to keep (e.g. binary files, certificates, etc.)…

Once you have created this structure in your local computer and compressed it in a zip file, you already have an app ready to deploy, but before lets check some tips and tricks.

  1. Barbara Docker tips and tricks

 While creating the zip file, consider the following important points:

  • Docker-compose YAML file can only be named docker-compose.yaml or docker-compose.yml, otherwise, docker installation will fail.
  • All persistence files/folders must be placed inside the “persist” folder in the ZIP root folder
  • You can add other files/folders into the zip to be be used to build containers but note that they will be replaced/deleted if the docker app is updated
  • Native docker volumes are also allowed
  • Only bind mounts are allowed, but only if that mount point (host side) contains “./persist/”, “./appconfig” or “./sys/”  at the beginning.
  • Privileged containers are not allowed
  • Admin-related capabilities are not allowed
  • Devices access must be declared explicitly which means you have to add the following text within you docker-compose.yaml file
  1. Deploying you newly created app

Barbara applications are organised in the App Library which can be accessed by the Library button in the centre of the upper bar of Barbara Panel

  • Once in the Library, push the “ADD NEW APP” button and the right top corner of the Panel, and fill the necessary information. Ensure the “User Docker” checkbox is selected.
  • Once the application is created, you can upload the zip file, that will be the first version of the application. For that, click on the name of the new application created, and click the button “ADD NEW VERSION” and the right top corner of the Panel, and fill the necessary information.

Congratulations! Your application is now ready to be deployed, you can do it the same way you deployed the test applications included in the starter kit. Basically:

  • Go to the devices view by clicking on the “DEVICES” button in the center of the upper bar of Barbara Panel
  • Click on the device you want to deploy the app into
  • Create a new CARD selecting Docker application
  • Select your application
  • Enable the logs and check the status and logs of your deployment
  • If you have problem while your application is starting do not hesitate to contact the Barbara support team!
  1. Managing variables within your application (APP-CONFIG and SECRETS)

If you have gone through the deployment process of the example applications, you have probably noticed that many of them used the concept of SECRETS, CREDENTIALS, GLOBAL APP-CONFIG and LOCAL APP CONFIG. These are files that contain dynamic information that can be read from insider your application. Typical information that is for example users and passwords to access your app (these must be in SECRETS or CREDENTIALS) or URL, IP, ports your application needs to connect to (these can be in LOCAL or GLOBAL APP-CONFIG).

  • CREDENTIALS are used to log into private docker repositories so you can download images from them. They are not accessible from the apps, the system or the docker daemon. 
  • SECRETS are global variables you define in your device and may be referenced from the different apps you install in your device (our sample apps within the Starter Kit, for instance, establish several Secrets to configure each app). If you establish a Secret you can refer to it in your app’s code by using the Secret name as the variable name 

Establishing a Secret in Barbara Platform

Referencing the Secret in your app’s code

How you organize your variables is up to you, but if you have any questions while developing your apps feel free to contact Barbara support team.

In order to ensure your SECRETS, GLOBAL and LOCAL APP-CONFIG variables are accessible from your applications, the following Volume mounts need to be added into your app Docker Compose Yaml file:

Once that volumes are mounted we will have access within our docker to 2 files /appconfig/global.json and /appconfig/appconfig.json.

These files will be kept updated with the content that we have in Barbara panel and react to the changes made, so we only need to add a function to our application that is in charge of reading those files and using the data for its configuration.

For example, if we add the following object to your Local App Config File and click the SEND button:

You can access it from within your Docker container the same way you would access a local json file. This is an example of a python program accessing this variable:

Was this article helpful?

Related Articles

Need Support?
Can’t find the answer you’re looking for? Don’t worry we’re here to help!
Contact Support