Addons provide a way to extend and customise images in Anbox Cloud. Once you have created addons, you can create hooks for them that are triggered based on events in the container life cycle. You can create addons independently and later attach it to individual applications.
To create or update an addon, you need a specific file structure for the directory containing your addon files. In the directory where you created your addon files, also create the following:
- A file named
manifest.yaml. See Addon manifest to learn about valid keys in an addon manifest file.
- A directory named
hooks. This directory must contain at least one executable file with a valid hook name.
Other files in the addon directory are bundled with the addon. They can be accessed in a hook by using the
$ADDON_DIR environment variable.
cat "$ADDON_DIR"/public_key.pem >> ~/.ssh/authorized_keys
To create an addon, you must provide the Anbox Management Client (AMC) with either of the following:
- The addon directory
- A tarball containing the required addon file structure
- A zip archive containing the required addon file structure
Addons must be created with careful consideration to not affect performance adversely. A good addon is light-weight and targeted for the necessary applications.
Here are some good practices to consider when creating addons:
Keep addons light
Addons are executed synchronously. Any addon that performs long-running operations (for example, downloading large files, installing packages on regular containers or querying unresponsive services) will delay an application from starting.
CONTAINER_TYPE environment variable to run only on the specified container type. Doing so runs the code in your hooks only when necessary.
Use global addons sparingly
Addons that are enabled for all applications can be useful, but they can add up quickly because whenever a global addon gets updated, a new application version is created. So if you use a global addon and that addon gets updated often, the disk capacity fills up fast.
Try to attach addons to individual applications unless you need a global addon.
Clean up your addons
For base containers, if your addon needs additional tools and dependencies during its installation, make sure you remove them afterwards (as part of the
post-stop hook). This will make your application image lighter and all containers launched from it will start faster.