diff --git a/config.yaml b/config.yaml index 54977b16..39b1c622 100644 --- a/config.yaml +++ b/config.yaml @@ -1,5 +1,5 @@ projectName: platform -image: jembi/platform:3.0.0-beta +image: jembi/platform:latest logPath: /tmp/logs packages: @@ -26,6 +26,7 @@ packages: - database-postgres - reprocess-mediator - fhir-ig-importer + - fhir-info-gateway profiles: - name: cdr-dw @@ -75,4 +76,3 @@ profiles: - openhim-mapping-mediator envFiles: - mpi.env - diff --git a/fhir-info-gateway/docker-compose.dev.yml b/fhir-info-gateway/docker-compose.dev.yml new file mode 100644 index 00000000..7b96e520 --- /dev/null +++ b/fhir-info-gateway/docker-compose.dev.yml @@ -0,0 +1,8 @@ +version: '3.9' + +services: + fhir-info-gateway: + ports: + - target: 8080 + published: 8880 + mode: host diff --git a/fhir-info-gateway/docker-compose.yml b/fhir-info-gateway/docker-compose.yml new file mode 100644 index 00000000..195ddcd9 --- /dev/null +++ b/fhir-info-gateway/docker-compose.yml @@ -0,0 +1,33 @@ +version: "3.9" +services: + fhir-info-gateway: + image: ${FHIR_INFO_GATEWAY_IMAGE} + networks: + openhim: + keycloak: + default: + environment: + TOKEN_ISSUER: ${KC_API_URL}/realms/${KC_REALM_NAME} + ACCESS_CHECKER: ${ACCESS_CHECKER} + PROXY_TO: ${MPI_PROXY_URL} + BACKEND_TYPE: ${BACKEND_TYPE} + RUN_MODE: ${RUN_MODE} + deploy: + replicas: ${FHIR_INFO_GATEWAY_INSTANCES} + placement: + max_replicas_per_node: ${FHIR_INFO_GATEWAY_MAX_REPLICAS_PER_NODE} + resources: + limits: + cpus: ${FHIR_INFO_GATEWAY_CPU_LIMIT} + memory: ${FHIR_INFO_GATEWAY_MEMORY_LIMIT} + reservations: + cpus: ${FHIR_INFO_GATEWAY_CPU_RESERVE} + memory: ${FHIR_INFO_GATEWAY_MEMORY_RESERVE} +networks: + openhim: + name: openhim_public + external: true + keycloak: + name: keycloak_public + external: true + default: diff --git a/fhir-info-gateway/package-metadata.json b/fhir-info-gateway/package-metadata.json new file mode 100644 index 00000000..bfb968be --- /dev/null +++ b/fhir-info-gateway/package-metadata.json @@ -0,0 +1,23 @@ +{ + "id": "fhir-info-gateway", + "name": "FHIR Info Gateway", + "description": "Implement the FHIR Info Gateway as a platform package which sits between the OpenHIM and MPI Mediator and any other direct FHIR access", + "type": "infrastructure", + "version": "0.0.1", + "dependencies": ["mpi-mediator"], + "environmentVariables": { + "MPI_PROXY_URL": "http://localhost:5001", + "ACCESS_CHECKER": "patient", + "RUN_MODE": "DEV", + "FHIR_INFO_GATEWAY_IMAGE": "jembi/fhir-info-gateway:v0.0.1", + "BACKEND_TYPE": "HAPI", + "KC_API_URL": "http://identity-access-manager-keycloak:9088", + "KC_REALM_NAME": "platform-realm", + "FHIR_INFO_GATEWAY_INSTANCES": "1", + "FHIR_INFO_GATEWAY_MAX_REPLICAS_PER_NODE": "1", + "FHIR_INFO_GATEWAY_CPU_LIMIT": "0", + "FHIR_INFO_GATEWAY_MEMORY_LIMIT": "2G", + "FHIR_INFO_GATEWAY_CPU_RESERVE": "0.05", + "FHIR_INFO_GATEWAY_MEMORY_RESERVE": "500M" + } +} diff --git a/fhir-info-gateway/swarm.sh b/fhir-info-gateway/swarm.sh new file mode 100644 index 00000000..2f89da06 --- /dev/null +++ b/fhir-info-gateway/swarm.sh @@ -0,0 +1,81 @@ +#!/bin/bash + +declare ACTION="" +declare MODE="" +declare COMPOSE_FILE_PATH="" +declare UTILS_PATH="" +declare SERVICE_NAMES=() +declare STACK="fhir-info-gateway" + +function init_vars() { + ACTION=$1 + MODE=$2 + + COMPOSE_FILE_PATH=$( + cd "$(dirname "${BASH_SOURCE[0]}")" || exit + pwd -P + ) + + UTILS_PATH="${COMPOSE_FILE_PATH}/../utils" + + SERVICE_NAMES=( + "fhir-info-gateway" + ) + + readonly ACTION + readonly MODE + readonly COMPOSE_FILE_PATH + readonly UTILS_PATH + readonly SERVICE_NAMES + readonly STACK +} + +# shellcheck disable=SC1091 +function import_sources() { + source "${UTILS_PATH}/docker-utils.sh" + source "${UTILS_PATH}/log.sh" +} + +function initialize_package() { + local package_dev_compose_filename="" + if [[ "${MODE}" == "dev" ]]; then + log info "Running package in DEV mode" + package_dev_compose_filename="docker-compose.dev.yml" + else + log info "Running package in PROD mode" + fi + + ( + docker::deploy_service $STACK "${COMPOSE_FILE_PATH}" "docker-compose.yml" "$package_dev_compose_filename" + ) || { + log error "Failed to deploy package" + exit 1 + } +} + +function destroy_package() { + docker::stack_destroy "$STACK" +} + +main() { + init_vars "$@" + import_sources + + if [[ "${ACTION}" == "init" ]] || [[ "${ACTION}" == "up" ]]; then + log info "Running package in Single node mode" + + 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 "$@" diff --git a/interoperability-layer-openhim/docker-compose.yml b/interoperability-layer-openhim/docker-compose.yml index 518d93dc..1a3ba685 100644 --- a/interoperability-layer-openhim/docker-compose.yml +++ b/interoperability-layer-openhim/docker-compose.yml @@ -24,6 +24,10 @@ services: - api_openid_clientId=${KC_OPENHIM_CLIENT_ID} - api_openid_clientSecret=${KC_OPENHIM_CLIENT_SECRET} - openhimConsoleBaseUrl=${OPENHIM_CONSOLE_BASE_URL} + - authentication_enableJWTAuthentication=true + - authentication_jwt_jwksUri=${KC_API_URL}/realms/${KC_REALM_NAME}/protocol/openid-connect/certs + - authentication_jwt_algorithms=RS256 + - authentication_jwt_issuer=${KC_FRONTEND_URL}/realms/${KC_REALM_NAME} deploy: replicas: ${OPENHIM_CORE_INSTANCES} placement: