Script
A swarm.sh file acts as an entry point to your package and runs within the instant container during deploy.
Two arguments are passed by default into the swarm script
- $1 is the action type ( init|up|down|destroy )
- $2 is the MODE in which it is run (dev)
Due to this script running in the instant container, all references made to files within the package folder would need to be prefixed with the PACKAGE_PATH variable
To supply config option to your package, make use of env vars which will be made available to this script and therefore to any docker command that you execute (so you may use env vars in your compose files for example). There are various options on the CLI via flags or the config file to supply env var files or env vars themselves.
As a coding standard we encourage use of the
Should you use VS Code for editing we suggest the pinage404.bash-extension-pack
Lines 2 & 3 extract the two arguments that instant provides to this script during any deploy command involving this package ie. the ACTION and MODE respectively.
Lines 6-9 retrieve the current path to this swarm.sh file which should exist at the root of your package. This path may then be used to reference any files within the package eg. docker-compose.yml.
Lines 12-32 define and execute a main block within which all our executable code will run. This is done to preserve the scope of any locally scoped variables used in the script.
Utility functions
A number of bash utility functions are also provided for more complex tasks relating to docker or common tasks that are made simpler. Please see the for a list of all available utility functions.