Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PLAT-524 #164

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
6 changes: 3 additions & 3 deletions analytics-datastore-clickhouse/swarm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ main() {
clickhouse_dev_compose_param="-c ${COMPOSE_FILE_PATH}/docker-compose.cluster.dev.yml"
fi

try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.cluster.yml $clickhouse_dev_compose_param instant" "Failed to deploy Analytics Datastore Clickhouse"
try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.cluster.yml $clickhouse_dev_compose_param --with-registry-auth instant" "Failed to deploy Analytics Datastore Clickhouse"

docker::await_container_startup analytics-datastore-clickhouse-01
docker::await_container_status analytics-datastore-clickhouse-01 Running
Expand All @@ -52,14 +52,14 @@ main() {
clickhouse_dev_compose_param="-c ${COMPOSE_FILE_PATH}/docker-compose.dev.yml"
fi

try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml $clickhouse_dev_compose_param instant" "Failed to deploy Analytics Datastore Clickhouse"
try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml $clickhouse_dev_compose_param --with-registry-auth instant" "Failed to deploy Analytics Datastore Clickhouse"
docker::await_container_startup analytics-datastore-clickhouse
docker::await_container_status analytics-datastore-clickhouse Running
fi

log info "Setting config digests"
config::set_config_digests "$COMPOSE_FILE_PATH"/importer/docker-compose.config.yml
try "docker stack deploy -c ${COMPOSE_FILE_PATH}/importer/docker-compose.config.yml instant" "Failed to start config importer"
try "docker stack deploy -c ${COMPOSE_FILE_PATH}/importer/docker-compose.config.yml --with-registry-auth instant" "Failed to start config importer"

log info "Waiting to give core config importer time to run before cleaning up service"

Expand Down
8 changes: 4 additions & 4 deletions analytics-datastore-elastic-search/swarm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import_elastic_index() {
# TODO: (castelloG) [PLAT-255] Add support for multiple index imports
log info "Importing Elasticsearch index mapping"
config::set_config_digests "${COMPOSE_FILE_PATH}"/importer/docker-compose.config.yml
try "docker stack deploy -c ${COMPOSE_FILE_PATH}/importer/docker-compose.config.yml instant" "Failed to start elastic search config importer"
try "docker stack deploy -c ${COMPOSE_FILE_PATH}/importer/docker-compose.config.yml --with-registry-auth instant" "Failed to start elastic search config importer"
config::remove_stale_service_configs "${COMPOSE_FILE_PATH}"/importer/docker-compose.config.yml "elasticsearch"
config::remove_config_importer elastic-search-config-importer
}
Expand All @@ -56,7 +56,7 @@ fi

create_certs() {
log info "Creating certificates"
try "docker stack deploy -c $COMPOSE_FILE_PATH/docker-compose.certs.yml instant" "Creating certificates failed"
try "docker stack deploy -c $COMPOSE_FILE_PATH/docker-compose.certs.yml --with-registry-auth instant" "Creating certificates failed"
docker::await_container_startup create_certs
docker::await_container_status create_certs Complete

Expand Down Expand Up @@ -113,13 +113,13 @@ add_docker_configs() {
if [[ "$ACTION" == "init" ]]; then
if [[ "$STATEFUL_NODES" == "cluster" ]]; then
create_certs
try "docker stack deploy -c $COMPOSE_FILE_PATH/docker-compose.cluster.yml instant" "Failed to deploy cluster"
try "docker stack deploy -c $COMPOSE_FILE_PATH/docker-compose.cluster.yml --with-registry-auth instant" "Failed to deploy cluster"
add_docker_configs

log info "Waiting for elasticsearch to start before automatically setting built-in passwords"
docker::await_container_status $leader_node Running
else
try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml $elastic_search_dev_compose_param instant" "Failed to deploy Analytics Datastore Elastic Search"
try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml $elastic_search_dev_compose_param --with-registry-auth instant" "Failed to deploy Analytics Datastore Elastic Search"

log info "Waiting for elasticsearch to start before automatically setting built-in passwords"
docker::await_container_status $leader_node Starting
Expand Down
33 changes: 33 additions & 0 deletions client-registry-jempi/importer/openhim/docker-compose.config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: '3.9'

services:
jempi-openhim-config-importer:
image: node:erbium-alpine
deploy:
restart_policy:
condition: none
environment:
OPENHIM_CORE_SERVICE_NAME: openhim-core
OPENHIM_MEDIATOR_API_PORT: 8080
OPENHIM_API_USERNAME: [email protected]
OPENHIM_API_PASSWORD: ${JEMPI_OPENHIM_PASSWORD}
NODE_TLS_REJECT_UNAUTHORIZED: 0
command: sh -c "node openhimConfig.js"
configs:
- source: openhim-config-importer-openhimConfig.js
target: /openhimConfig.js
- source: openhim-config-importer-openhim-import.json
target: /openhim-import.json

configs:
openhim-config-importer-openhimConfig.js:
file: ./openhimConfig.js
name: openhim-config-importer-openhimConfig.js-${openhim_config_importer_openhimConfig_js_DIGEST:?err}
labels:
name: openhim
openhim-config-importer-openhim-import.json:
file: ./openhim-import.json
name: openhim-config-importer-openhim-import.json-${openhim_config_importer_openhim_import_js_DIGEST:?err}
labels:
name: openhim

106 changes: 106 additions & 0 deletions client-registry-jempi/importer/openhim/openhim-import.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
{
"Channels": [
{
"methods": ["POST"],
"type": "http",
"allow": ["instant"],
"whitelist": [],
"authType": "private",
"matchContentTypes": [],
"properties": [],
"txViewAcl": [],
"txViewFullAcl": [],
"txRerunAcl": [],
"status": "enabled",
"rewriteUrls": false,
"addAutoRewriteRules": true,
"autoRetryEnabled": false,
"autoRetryPeriodMinutes": 60,
"routes": [
{
"type": "http",
"status": "enabled",
"forwardAuthHeader": false,
"name": "JeMPI Sync Receiver",
"secured": false,
"host": "jempi-sync-reciever",
"port": 50000,
"path": "",
"pathTransform": "",
"primary": true,
"username": "",
"password": ""
}
],
"requestBody": true,
"responseBody": true,
"rewriteUrlsConfig": [],
"name": "JeMPI Sync Receiver",
"urlPattern": "^/fhir/Patient.*$",
"priority": 10,
"matchContentRegex": null,
"matchContentXpath": null,
"matchContentValue": null,
"matchContentJson": null,
"pollingSchedule": null,
"tcpHost": null,
"tcpPort": null,
"updatedBy": {
"id": "605c8ddd9e66da001494935e",
"name": "Super User"
},
"alerts": []
},
{
"methods": ["POST"],
"type": "http",
"allow": ["instant"],
"whitelist": [],
"authType": "private",
"matchContentTypes": [],
"properties": [],
"txViewAcl": [],
"txViewFullAcl": [],
"txRerunAcl": [],
"status": "enabled",
"rewriteUrls": false,
"addAutoRewriteRules": true,
"autoRetryEnabled": false,
"autoRetryPeriodMinutes": 60,
"routes": [
{
"type": "http",
"status": "enabled",
"forwardAuthHeader": false,
"name": "JeMPI Async Receiver",
"secured": false,
"host": "jempi-async-reciever",
"port": 50000,
"path": "",
"pathTransform": "",
"primary": true,
"username": "",
"password": ""
}
],
"requestBody": true,
"responseBody": true,
"rewriteUrlsConfig": [],
"name": "JeMPI Async Receiver",
"urlPattern": "^/csv/?$",
"priority": 1,
"matchContentRegex": null,
"matchContentXpath": null,
"matchContentValue": null,
"matchContentJson": null,
"pollingSchedule": null,
"tcpHost": null,
"tcpPort": null,
"updatedBy": {
"id": "605c8ddd9e66da001494935e",
"name": "Super User"
},
"alerts": []
}
]
}
52 changes: 52 additions & 0 deletions client-registry-jempi/importer/openhim/openhimConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"use strict";

const fs = require("fs");
const https = require("https");
const path = require("path");

const OPENHIM_CORE_SERVICE_NAME = process.env.OPENHIM_CORE_SERVICE_NAME;
const OPENHIM_API_PASSWORD = process.env.OPENHIM_API_PASSWORD;
const OPENHIM_MEDIATOR_API_PORT = process.env.OPENHIM_MEDIATOR_API_PORT;
const OPENHIM_API_USERNAME = process.env.OPENHIM_API_USERNAME;

const authHeader = new Buffer.from(
`${OPENHIM_API_USERNAME}:${OPENHIM_API_PASSWORD}`
).toString("base64");

const jsonData = JSON.parse(
fs.readFileSync(path.resolve(__dirname, "openhim-import.json"))
);

const data = JSON.stringify(jsonData);

const options = {
protocol: "https:",
hostname: OPENHIM_CORE_SERVICE_NAME,
port: OPENHIM_MEDIATOR_API_PORT,
path: "/metadata",
method: "POST",
headers: {
"Content-Type": "application/json",
"Content-Length": data.length,
Authorization: `Basic ${authHeader}`,
},
};

const req = https.request(options, (res) => {
if (res.statusCode == 401) {
throw new Error(`Incorrect OpenHIM API credentials`);
}

if (res.statusCode != 201) {
throw new Error(`Failed to import OpenHIM config: ${res.statusCode}`);
}

console.log("Successfully imported OpenHIM config");
});

req.on("error", (error) => {
console.error("Failed to import OpenHIM config: ", error);
});

req.write(data);
req.end();
5 changes: 3 additions & 2 deletions client-registry-jempi/package-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "A patient matching and deduplicater for the platform",
"type": "infrastructure",
"version": "0.0.1",
"dependencies": [],
"dependencies": ["interoperability-layer-openhim"],
"environmentVariables": {
"STATEFUL_NODES": "single",
"JEMPI_KAFKA_01_MEMORY_LIMIT": "3G",
Expand Down Expand Up @@ -49,6 +49,7 @@
"JEMPI_CONTROLLER_IMAGE_TAG": "0.1.0",
"JEMPI_EM_CALCULATOR_IMAGE_TAG": "0.1.0",
"JEMPI_LINKER_IMAGE_TAG": "0.1.0",
"JEMPI_API_IMAGE_TAG": "0.1.0"
"JEMPI_API_IMAGE_TAG": "0.1.0",
"JEMPI_OPENHIM_PASSWORD": "instant101"
}
}
30 changes: 23 additions & 7 deletions client-registry-jempi/swarm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,19 @@ main() {
fi

if [[ "${ACTION}" == "init" ]] || [[ "${ACTION}" == "up" ]]; then
try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.kafka.yml instant" "Failed to deploy Client Registry - JeMPI (kafka.yml)"
try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.kafka.yml --with-registry-auth instant" "Failed to deploy Client Registry - JeMPI (kafka.yml)"

docker::await_service_ready jempi-kafka-01
docker::await_service_ready jempi-kafka-02
docker::await_service_ready jempi-kafka-03

try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.kafdrop.yml $kafdrop_dev_compose_param instant" "Failed to deploy Client Registry - JeMPI (kafdrop.yml)"
try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.kafdrop.yml $kafdrop_dev_compose_param --with-registry-auth instant" "Failed to deploy Client Registry - JeMPI (kafdrop.yml)"

docker::await_service_ready jempi-kafdrop

config::set_config_digests "${COMPOSE_FILE_PATH}"/importer/docker-compose.config.yml

try "docker stack deploy -c ${COMPOSE_FILE_PATH}/importer/docker-compose.config.yml instant" "Failed to deploy jempi-kafka-config-importer"
try "docker stack deploy -c ${COMPOSE_FILE_PATH}/importer/docker-compose.config.yml --with-registry-auth instant" "Failed to deploy jempi-kafka-config-importer"

log info "Waiting to give JeMPI Kafka config importer time to run before cleaning up service"

Expand All @@ -85,19 +85,19 @@ main() {

config::remove_stale_service_configs "${COMPOSE_FILE_PATH}"/importer/docker-compose.config.yml "jempi-kafka"

try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.dgraph-zero.yml $dgraph_zero_dev_compose_param $dgraph_zero_cluster_compose_param instant" "Failed to deploy Client Registry - JeMPI (dgraph-zero.yml)"
try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.dgraph-zero.yml $dgraph_zero_dev_compose_param $dgraph_zero_cluster_compose_param --with-registry-auth instant" "Failed to deploy Client Registry - JeMPI (dgraph-zero.yml)"

docker::await_service_ready jempi-zero-01

try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.dgraph.yml $dgraph_dev_compose_param $dgraph_cluster_compose_param instant" "Failed to deploy Client Registry - JeMPI (dgraph.yml)"
try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.dgraph.yml $dgraph_dev_compose_param $dgraph_cluster_compose_param --with-registry-auth instant" "Failed to deploy Client Registry - JeMPI (dgraph.yml)"

docker::await_service_ready jempi-alpha-01
docker::await_service_ready jempi-alpha-02
docker::await_service_ready jempi-alpha-03

docker::await_service_ready jempi-ratel

try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.combined.yml $combined_dev_compose_param instant" "Failed to deploy Client Registry - JeMPI (combined.yml)"
try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.combined.yml $combined_dev_compose_param --with-registry-auth instant" "Failed to deploy Client Registry - JeMPI (combined.yml)"

docker::await_service_ready jempi-async-receiver
docker::await_service_ready jempi-sync-receiver
Expand All @@ -106,10 +106,23 @@ main() {
docker::await_service_ready jempi-em-calculator
docker::await_service_ready jempi-linker

try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.api.yml $api_dev_compose_param instant" "Failed to deploy Client Registry - JeMPI (api.yml)"
try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.api.yml $api_dev_compose_param --with-registry-auth instant" "Failed to deploy Client Registry - JeMPI (api.yml)"

docker::await_service_ready jempi-api

if docker service ps -q instant_openhim-core &>/dev/null; then
config::set_config_digests "${COMPOSE_FILE_PATH}"/importer/openhim/docker-compose.config.yml

try "docker stack deploy -c ${COMPOSE_FILE_PATH}/importer/openhim/docker-compose.config.yml --with-registry-auth instant" "Failed to deploy jempi-openhim-config-importer"

log info "Waiting to give JeMPI Openhim config importer time to run before cleaning up service"

config::remove_config_importer jempi-openhim-config-importer
config::await_service_removed instant_jempi-openhim-config-importer
else
log warn "Service 'interoperability-layer-openhim' does not appear to be running... skipping configuring of async/sync JeMPI channels"
fi

docker::deploy_sanity "${service_names[@]}"
elif [[ "${ACTION}" == "down" ]]; then
log info "Scaling down client-registry-jempi"
Expand All @@ -124,6 +137,9 @@ main() {
docker::service_destroy "$service_name"
done

docker::service_destroy jempi-kafka-config-importer
docker::service_destroy jempi-openhim-config-importer

docker::try_remove_volume jempi-kafka-01-data
docker::try_remove_volume jempi-kafka-02-data
docker::try_remove_volume jempi-kafka-03-data
Expand Down
8 changes: 4 additions & 4 deletions client-registry-santempi/swarm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,17 @@ main() {
fi

if [ "$ACTION" == "init" ]; then
try "docker stack deploy -c $COMPOSE_FILE_PATH/docker-compose-postgres.yml $postgres_cluster_compose_param $postgres_dev_compose_param instant" "Failed to deploy SanteMPI Postgres"
try "docker stack deploy -c $COMPOSE_FILE_PATH/docker-compose-postgres.yml $postgres_cluster_compose_param $postgres_dev_compose_param --with-registry-auth instant" "Failed to deploy SanteMPI Postgres"

await_postgres_start

try "docker stack deploy -c ""$COMPOSE_FILE_PATH""/docker-compose.yml $sante_mpi_dev_compose_param instant" "Failed to deploy SanteMPI"
try "docker stack deploy -c ""$COMPOSE_FILE_PATH""/docker-compose.yml $sante_mpi_dev_compose_param --with-registry-auth instant" "Failed to deploy SanteMPI"
elif [ "$ACTION" == "up" ]; then
try "docker stack deploy -c $COMPOSE_FILE_PATH/docker-compose-postgres.yml $postgres_cluster_compose_param $postgres_dev_compose_param instant" "Failed to stand up SanteMPI Postgres"
try "docker stack deploy -c $COMPOSE_FILE_PATH/docker-compose-postgres.yml $postgres_cluster_compose_param $postgres_dev_compose_param --with-registry-auth instant" "Failed to stand up SanteMPI Postgres"

await_postgres_start

try "docker stack deploy -c ""$COMPOSE_FILE_PATH""/docker-compose.yml $sante_mpi_dev_compose_param instant" "Failed to stand up SanteMPI"
try "docker stack deploy -c ""$COMPOSE_FILE_PATH""/docker-compose.yml $sante_mpi_dev_compose_param --with-registry-auth instant" "Failed to stand up SanteMPI"

if [[ "$STATEFUL_NODES" == "cluster" ]]; then
docker::deploy_sanity santedb-www santedb-mpi santempi-psql-1 santempi-psql-2 santempi-psql-3
Expand Down
4 changes: 2 additions & 2 deletions dashboard-visualiser-jsreport/swarm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ main() {
if [[ "${ACTION}" == "init" ]] || [[ "${ACTION}" == "up" ]]; then
unbound_ES_HOSTS_check

try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml $js_report_dev_compose_param $js_report_dev_mount_compose_param instant" "Failed to deploy JS Report"
try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml $js_report_dev_compose_param $js_report_dev_mount_compose_param --with-registry-auth instant" "Failed to deploy JS Report"

if [[ "${JS_REPORT_DEV_MOUNT}" != "true" ]]; then
log info "Verifying JS Report service status"
config::await_service_running "dashboard-visualiser-jsreport" "${COMPOSE_FILE_PATH}"/docker-compose.await-helper.yml "${JS_REPORT_INSTANCES}"

config::set_config_digests "${COMPOSE_FILE_PATH}"/importer/docker-compose.config.yml
try "docker stack deploy -c ${COMPOSE_FILE_PATH}/importer/docker-compose.config.yml instant" "Failed to start config importer"
try "docker stack deploy -c ${COMPOSE_FILE_PATH}/importer/docker-compose.config.yml --with-registry-auth instant" "Failed to start config importer"

config::remove_config_importer "jsreport-config-importer"
config::remove_stale_service_configs "$COMPOSE_FILE_PATH"/importer/docker-compose.config.yml "jsreport"
Expand Down
Loading