06-07-2020 03:05 AM
Hello,
is there a way to pre-populate the /data partition with files while building the app bundle? I'd like to put a configuration file there or client certificates to authenticate and/or authorize the app with a remote server and be able to modify them without re-deploying the whole app.
Thanks!
Silla Rizzoli
06-11-2020 07:39 AM
The directory defined by the environement variable ${CAF_APP_APPDATA_DIR} can be used to upload and download files with the IOx application. This is typically used to configuration files and certificates which I believe is also your question.
You can upload (or download - for example to backup) files to/from this directory using Cisco IOx Local Manager or the ioxclient utility. This space also persists when you upgrade the IOx application.
06-11-2020 07:50 AM
06-11-2020 08:40 AM - edited 06-11-2020 08:57 AM
Hello Silla -
You are right that "/data" is a Docker volume that becomes active only after the application activation. Therefore writing to that volume before deployment or activation is not an option. I see at least two ways you can address your problem as I understand it:
a) You can store your files as part of your application, and when your app starts a script will check if "/data" has been populated yet with those files. If not, copy the files from your IOx application to /data. If yes, continue.
b) In IOx there is a concept of bootstrapping: those are variables that can be passed to the application before it is running. They are part of your main IOx application in a file called 'package_config.ini' and those variables can be changed at activation time. This is an ideal place for the hostname of an MQTT server, admin password and so on. Check here for an example: https://github.com/etychon/iox-dumpenvvariables-aarch64
Emmanuel
06-15-2020 01:04 AM
Hello @Emmanuel Tychon,
thank you for your answer, helpful as always.
I'll explore the two options you described.
By the way, I'm playing with a IR1101 IOS-XE version 17.02.01, which has some support for docker, and I managed to run node-red for aarch64 unmodified on it (this image, to be precise - https://hub.docker.com/layers/nodered/node-red/latest/images/sha256-069bf5081169ca9806c9bf96a84e3998907ea8e331c844e6486f016e432a2c5b?context=explore), using the following "docker run" command line switches (--user node-red:node-red --expose 1880 --workdir /usr/src/node-red). I opted not to delete the container every time and when I restart it I know that my work has been saved on /data, because my flows are still there and node-red is configured to save them on /data (ENTRYPOINT ["npm" "start" "--cache" "/data/.npm" "--" "--userDir" "/data"] - I specified the same entrypoint on package.yaml too); however, I cannot see any files on /data when I browse it using the https interface.
Maybe it has something to do with the fact that /data is specified as a separate volume in the docker image; do you have any docs on how exactly docker and IOx interact?
Thanks again!
Best regards
Silla Rizzoli
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide