How to create an Instant OpenHIE package
info
The Instant OpenHIE architecture, codebase, and documentation are under active development and are subject to change. While we encourage adoption and extension of the Instant OpenHIE framework, we do not consider this ready for production use at this stage.
Packages are a way of allowing a group of applications to be setup and configured to enable a particular set of functionality. Each package MUST include the following:
docker-compose.*.yml
files to setup and configure the necessary applications in Docker Compose- Deployment and service resource files (and any other necessary resource files) to setup and configure the necessary applications in Kubernetes
- A
instant.json
file that holds metadata about the package - Bash scripts that accept a particular set of commands (init, up, down, and destroy) and execute these Docker Compose and Kubernetes infrastructure files and any other necessary processing and configuration to perform the required command.
#
Docker Compose filesAll Docker Compose files should by convention be contained in a ./docker
directory in the root of the package directory. It is often useful to split up Docker Compose files into separate files with different purposes. For example:
docker-compose.yml
for the main application setup and orchestrationdocker-compose.config.yml
for starting short lived containers that configure the applications or add any test data that is necessarydocker-compose.dev.yml
for over-ridding options in the main compose file to allow for easier development. For example, to expose all ports to the host even those that should be protected
#
Kubernetes resourcesAll Kubernetes files should by convention be contained in a ./kubernetes
directory in the root of the package directory. It is recommended to use the declarative form of Kubernetes resources. The key resources to define are deployments and services for each component.
Config containers can be executed as job resources with an init container. These temporary containers only configure the main application once the service has started up.
#
instant.jsonThis file should be in the root directory of the package and provide metadata about the package itself along with any dependencies:
#
Bash scriptsTwo bash scripts are required in each package:
./docker/compose.sh
- to configure, start and stop the applications using Docker Compose./kubernetes/main/k8s.sh
- to configure, start and stop the applications using Kubernetes
Each of these scripts should accept one of the following commands (i.e. ./compose.sh <command>
):
init
- start all the applications in this package and performs any necessary pre-processing of the infrastructure filesup
- start all the applications in this packagedown
- stop all the applications in this packagedestroy
- delete all the application containers in this package and all their stored data
For example, a compose.sh
script could look like this:
A k8s.sh
script could look like this:
The Instant OpenHIE executable will look for these scripts and ensure that they are executed to start-up a package. Packages will be started in their dependency order beginning with the core
package.
#
How to execute your new packageThe following mechanism for adding a package is useful for package development.
The preferred method for adding custom packages to your Instant instance will be to add the package repo GitHub url to the config - however this feature is still in development.
#
Yarn (Dev)Copy your package into the root directory of this Instant OpenHIE project.
Run as normal:
#
Docker or Kubernetes without the Instant OpenHIE repoThe Instant OpenHIE project is available as a Docker image therefore we do not need the whole GitHub repository to run the containers.
For a minimum Instant OpenHIE set up, download this deploy script from GitHub.
Once downloaded make sure it's executable: sudo chmod +x deploy.sh
Then, run the following command to add your custom package and initialise the system in docker.
To remove the instant project, run the following:
./deploy destroy -t docker core covid19surveillance
The custom package location is not needed for
up
,down
, ordestroy
commands on an existing system.
To initialise kubernetes, run the following:
Multiple custom packages can be chained together as follows:
#
DockerTo add a custom package to your instant instance, use the following flag
-c
--custom-package
We hope to support package url references soon
To add multiple custom packages, list each package location with the flag.
-c="/path/to/package_1" -c="/path/to/package_2"
Below is an example of an entire init
command.
If you had downloaded the who-covid19-surveillance-package repository onto your machine you could reference it as follows:
Once a custom package has been added to the project, it does not need to be referenced in future commands as the data has been persisted in the shared volume. The examples below continue on from the previous covid19 package initialisation.
yarn docker:instant down core covid19surveillance
yarn docker:instant up core covid19surveillance
yarn docker:instant test core covid19surveillance
yarn docker:instant destroy core covid19surveillance
#
KubernetesTo add a custom package to your instant instance, use the following flag
-c
--custom-package
We hope to support package url references soon
To add multiple custom packages, list each package location with the flag.
-c="/path/to/package_1" -c="/path/to/package_2"
Docker is the default deploy environment. To use Kubernetes, add the target flag -t
. For example:
-t k8s
-t kubernetes
Below is an example of an entire init
command.
If you had downloaded the who-covid19-surveillance-package repository onto your machine you could reference it as follows:
Once a custom package has been added to the project, it does not need to be references in future commands as the data has been persisted in the shared volume. The examples below continue on from the previous covid19 package initialisation.
yarn docker:instant down -t k8s core covid19surveillance
yarn docker:instant up -t k8s core covid19surveillance
yarn docker:instant test -t k8s core covid19surveillance
yarn docker:instant destroy -t k8s core covid19surveillance