Skip to content

Commit

Permalink
Updating iSantePlus setup for custom modules and mysql extraction (#85)
Browse files Browse the repository at this point in the history
* Updating iSantePlus setup for custom modules and mysql extraction

* network fix
  • Loading branch information
pmanko authored Oct 24, 2024
1 parent 3149642 commit da4818c
Show file tree
Hide file tree
Showing 24 changed files with 384 additions and 81 deletions.
15 changes: 14 additions & 1 deletion build-custom-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,20 @@ docker build \
-t lnsp-mediator:local \
-f projects/lnsp-mediator/Dockerfile \
projects/lnsp-mediator \


# Load Env vars from json file environmentVariables field
filepath="./packages/emr-isanteplus/package-metadata.json"
envs=$(jq -r '.environmentVariables | to_entries | .[] | "\(.key)=\(.value)"' $filepath)

# Export each environment variable
while IFS= read -r line; do
export "$line"
done <<< "$envs"

docker compose \
-f packages/emr-isanteplus/docker-compose.yml \
build

# Build the Platform to contain the above custom builds
./build-image.sh

Expand Down
2 changes: 2 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ packages:
- fhir-datastore-hapi-fhir
- monitoring
- database-postgres
- database-mysql
- identity-access-manager-keycloak
- client-registry-opencr
- analytics-datastore-elastic-search
Expand All @@ -24,6 +25,7 @@ packages:
- lnsp-mediator



profiles:
- name: dev
packages:
Expand Down
12 changes: 8 additions & 4 deletions mk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@
#./instant package down -n interoperability-layer-openhim --env-file .env
#./instant package up -n interoperability-layer-openhim --env-file .env

#mysql
#./instant package remove -n database-mysql --env-file .env
#./instant package init -n database-mysql --env-file .env

#isanteplus

#./instant package remove -n emr-isanteplus --env-file .env
#./instant package init -n emr-isanteplus --env-file .env
./instant package remove -n emr-isanteplus --env-file .env
./instant package init -n emr-isanteplus --env-file .env
# ./instant package down -n emr-isanteplus --env-file .env
# ./instant package up -n emr-isanteplus --env-file .env

Expand Down Expand Up @@ -89,8 +93,8 @@


# LNSP Mediator
./instant package remove -n lnsp-mediator --env-file .env
./instant package init -n lnsp-mediator --env-file .env
#./instant package remove -n lnsp-mediator --env-file .env
#./instant package init -n lnsp-mediator --env-file .env -d
# ./instant package down -n lnsp-mediator --env-file .env -d
# ./instant package up -n lnsp-mediator --env-file .env -d

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
version: "3.9"

services:
isanteplus-mysql:
mysql:
image: ghcr.io/isanteplus/docker-isanteplus-db:vtestUpdatedDb
command: mysqld --character-set-server=utf8 --collation-server=utf8_general_ci --sql_mode=""
container_name: isanteplus-mysql
environment:
- MYSQL_DATABASE=${OMRS_MYSQL_DB_NAME}
- MYSQL_ROOT_PASSWORD=${OMRS_MYSQL_ROOT_PW}
- MYSQL_USER=${OMRS_CONFIG_CONNECTION_USERNAME}
- MYSQL_PASSWORD=${OMRS_CONFIG_CONNECTION_PASSWORD}
- MYSQL_DATABASE=${MYSQL_DB_NAME}
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PW}
- MYSQL_USER=${MYSQL_CONNECTION_USERNAME}
- MYSQL_PASSWORD=${MYSQL_CONNECTION_PASSWORD}
- MYSQL_ROOT_HOST=% # Allow docker containers to connect to mysql
volumes:
- "isanteplus-mysql-1-data:/var/lib/mysql"
- "/var/lib/mysql"
networks:
- openhim
- mysql
configs:
- source: mysql.cnf
target: /etc/mysql/conf.d/custom.cnf
Expand All @@ -24,13 +23,10 @@ configs:
file: ./config/mysql.cnf
name: mysql.cnf
labels:
name: isanteplus

volumes:
isanteplus-mysql-1-data:
name: mysql

networks:
openhim:
mysql:
external: true
name: openhim_public
name: mysql_public

17 changes: 17 additions & 0 deletions packages/database-mysql/package-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"id": "database-mysql",
"name": "MySQL",
"description": "MySQL database",
"type": "infrastructure",
"version": "0.0.0",
"dependencies": [],
"environmentVariables": {
"MYSQL_CONNECTION_USERNAME":"mysqluser",
"MYSQL_CONNECTION_PASSWORD":"mysqlpw",
"MYSQL_DB_NAME":"openmrs",
"MYSQL_ROOT_PW": "debezium"
}
}



92 changes: 92 additions & 0 deletions packages/database-mysql/swarm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/bin/bash

declare ACTION=""
declare MODE=""
declare COMPOSE_FILE_PATH=""
declare UTILS_PATH=""
declare STACK="mysql"

function init_vars() {
ACTION=$1
MODE=$2

COMPOSE_FILE_PATH=$(
cd "$(dirname "${BASH_SOURCE[0]}")" || exit
pwd -P
)

UTILS_PATH="${COMPOSE_FILE_PATH}/../utils"

readonly ACTION
readonly MODE
readonly COMPOSE_FILE_PATH
readonly UTILS_PATH
readonly STACK
}

# shellcheck disable=SC1091
function import_sources() {
source "${UTILS_PATH}/docker-utils.sh"
source "${UTILS_PATH}/config-utils.sh"
source "${UTILS_PATH}/log.sh"
}

function initialize_package() {


# if [ "${MODE}" == "dev" ]; then
# log info "Running package in DEV mode"
# postgres_dev_compose_filename="docker-compose-postgres.dev.yml"
# hapi_fhir_dev_compose_filename="docker-compose.dev.yml"
# else
log info "Running package in PROD mode"
#fi

# if [ "${CLUSTERED_MODE}" == "true" ]; then
# postgres_cluster_compose_filename="docker-compose-postgres.cluster.yml"
# fi

(
docker::deploy_service "$STACK" "${COMPOSE_FILE_PATH}" "docker-compose.yml"
) ||
{
log error "Failed to deploy package"
exit 1
}
}

function destroy_package() {
docker::stack_destroy "$STACK"

if [[ "${CLUSTERED_MODE}" == "true" ]]; then
log warn "Volumes are only deleted on the host on which the command is run. Postgres volumes on other nodes are not deleted"
fi

docker::prune_configs "isanteplus"
}

main() {
init_vars "$@"
import_sources

if [[ "${ACTION}" == "init" ]] || [[ "${ACTION}" == "up" ]]; then
if [[ "${CLUSTERED_MODE}" == "true" ]]; then
log info "Running package in Cluster node mode"
else
log info "Running package in Single node mode"
fi

initialize_package
elif [[ "${ACTION}" == "down" ]]; then
log info "Scaling down package"

docker::scale_services "$STACK" 0
elif [[ "${ACTION}" == "destroy" ]]; then
log info "Destroying package"
destroy_package
else
log error "Valid options are: init, up, down, or destroy"
fi
}

main "$@"
3 changes: 3 additions & 0 deletions packages/emr-isanteplus/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from ghcr.io/isanteplus/docker-isanteplus-server:v2.3.4

add ./config/custom_modules /custom_modules
Empty file.
Binary file modified packages/emr-isanteplus/config/custom_modules/labintegration-2.2.1-SNAPSHOT.omod
100755 → 100644
Binary file not shown.
Binary file not shown.
41 changes: 13 additions & 28 deletions packages/emr-isanteplus/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ version: '3.9'

services:
isanteplus:
image: ghcr.io/isanteplus/docker-isanteplus-server:v2.3.4
#image: ghcr.io/isanteplus/docker-isanteplus-server:v2.3.4
# See ./build-custom-images.sh for how to build local image to include custom modules
image: itechuw/docker-isanteplus-server:local
build:
context: .
dockerfile: Dockerfile
environment:
- OMRS_JAVA_MEMORY_OPTS=${OMRS_JAVA_MEMORY_OPTS}
- OMRS_CONFIG_CONNECTION_SERVER=${OMRS_CONFIG_CONNECTION_SERVER}
Expand All @@ -19,44 +24,24 @@ services:
- isanteplus-data:/openmrs/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
ports:
- 1046:1044
networks:
- public
- openhim
configs:
- target: /custom_modules/labintegration-2.2.1-SNAPSHOT.omod
source: labintegration-2.2.1-SNAPSHOT.omod


configs:
labintegration-2.2.1-SNAPSHOT.omod:
file: ./config/custom_modules/labintegration-2.2.1-SNAPSHOT.omod
name: labintegration-2.2.1-SNAPSHOT.omod
labels:
name: labintegration-2.2.1-SNAPSHOT
# isanteplusreports-1.1-SNAPSHOT.omod:
# file: ./config/custom_modules/isanteplusreports-1.1-SNAPSHOT.omod
# name: isanteplusreports-1.1-SNAPSHOT.omod
# labels:
# name: isanteplusreports
- reverse-proxy
- mysql

volumes:
isanteplus-data:
custom_modules:
driver: local

#etc/timezone:
#etc/localtime:


networks:
public:
external: true
name: isanteplus_public
mysql:
external: true
name: mysql_public
reverse-proxy:
name: reverse-proxy_public
openhim:
external: true
name: openhim_public



Expand Down
9 changes: 3 additions & 6 deletions packages/emr-isanteplus/package-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,18 @@
"version": "0.0.0",
"dependencies": [],
"environmentVariables": {
"OMRS_CONFIG_CONNECTION_SERVER": "isanteplus-mysql",
"OMRS_CONFIG_CONNECTION_SERVER": "mysql",
"OMRS_CONFIG_CREATE_DATABASE_USER": "false",
"OMRS_CONFIG_CREATE_TABLES":"false",
"OMRS_CONFIG_ADD_DEMO_DATA": "false",
"OMRS_CONFIG_CONNECTION_URL":"jdbc:mysql://isanteplus-mysql:3306/openmrs?autoReconnect=true",
"OMRS_CONFIG_CONNECTION_URL":"jdbc:mysql://mysql:3306/openmrs?autoReconnect=true",
"OMRS_CONFIG_HAS_CURRENT_OPENMRS_DATABASE":"true",
"OMRS_JAVA_SERVER_OPTS":"-Dfile.encoding=UTF-8 -server -Djava.security.egd=file:/dev/./urandom -Djava.awt.headless=true -Djava.awt.headlesslib=true",
"OMRS_CONFIG_CONNECTION_USERNAME":"mysqluser",
"OMRS_CONFIG_CONNECTION_PASSWORD":"mysqlpw",
"OMRS_DEV_DEBUG_PORT":"1044",
"OMRS_JAVA_MEMORY_OPTS":"-Xmx8192m -Xms4096m -XX:NewSize=512m",
"OMRS_MYSQL_DB_NAME":"openmrs",
"OMRS_MYSQL_ROOT_PW": "debezium"


"ISANTEPLUS_VERSION": "v2.3.4"
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/emr-isanteplus/swarm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function initialize_package() {
# fi

(
docker::deploy_service "$STACK" "${COMPOSE_FILE_PATH}" "docker-compose-mysql.yml"
#docker::deploy_service "$STACK" "${COMPOSE_FILE_PATH}" "docker-compose-mysql.yml"

docker::deploy_service "$STACK" "${COMPOSE_FILE_PATH}" "docker-compose.yml"
) ||
Expand Down
2 changes: 1 addition & 1 deletion packages/lnsp-mediator/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ services:
lnsp-mediator:
ports:
- target: 3000
published: 3300
published: 3000
mode: host
- target: 9229
published: 9229
Expand Down
Loading

0 comments on commit da4818c

Please sign in to comment.