It may be useful to run this adaptor in a local environment. The following is a step-by-step guide on how to set this up.
-
Pre-requisite: Set up NHS Digital OpenTest connection
-
Requirements:
- Docker - for example Docker for Windows
- Packer
- Python 3
- Pipenv
- git bash (to run .sh files below)
-
Set up Environment variable:
export BUILD_TAG='latest'
-
Run the
./build.sh
script found in the top level directory of this project. This will build the following docker containers which are required to run the MHS Adaptor locally.- Inbound service (An HTTP endpoint which spine communicates request back to you on)
- Outbound service (An HTTP endpoint which you submit requests for spine on)
- Routing service (An HTTP endpoint which the Outbound service uses internally to get routing and reliability information from spine)
- SCR Adaptor (An HTTP endpoint which can be used to simplify Summary Care Record interactions, and call the MHS adaptor for you)
-
Set up Environment variables. The environment variables
MHS_SECRET_PARTY_KEY
,MHS_SECRET_CLIENT_CERT
,MHS_SECRET_CLIENT_KEY
andMHS_SECRET_CA_CERTS
need to be set when running this command. These variables should be set as described here. A simple way of setting this up once is to create a bash fileconfigure-env-vars.sh
that looks like:
export MHS_SECRET_PARTY_KEY="your party key from NHS Digital here"
export MHS_SECRET_CLIENT_CERT=$'client cert from NHS Digital here'
export MHS_SECRET_CLIENT_KEY=$'client key from NHS Digital here'
export MHS_SECRET_CA_CERTS=$'ca certs from NHS Digital here'
and then run source configure-env-vars.sh
.
Optionally, add following environment variables to replace spine-route-lookup with INT SDS API Sandbox for routing and reliability lookup.
export MHS_OUTBOUND_ROUTING_LOOKUP_METHOD=SDS_API
export MHS_SDS_API_URL=https://sandbox.api.service.nhs.uk/spine-directory/FHIR/R4
export MHS_SDS_API_KEY=none
-
Ensure your OpenTest connectivity is enabled in OpenVPN. (This does not apply if you have an available HSCN connection)
-
Run
docker-compose up
. This will start the containers which have been built or pulled down, as described above. -
Depending on the OS the MHS is being run on, measures may have to be taken to allow public inbound traffic so that the async responses from Spine can access the MHS. For example on windows a inbound rule may be required in windows firewall to allow inbound traffic from the Spine through port 443.
-
Note that the
MHS_LOG_LEVEL
environment variable (as documented here) is set by default toNOTSET
in thedocker-compose.yml
file but should be changed if needed.
The Outbound service, Inbound Service and the Spine Lookup Service all expose a health-check endpoint which can also be used to facilitate health checks in a load balanced environment.
Each of these services exposes a /healthcheck
URL which, when called indicates healthy state by returning an empty HTTP 200 response.
In order to determine the ports on localhost
which these health-check endpoints are listening on, examine your local copy
of the docker-compose file.
To run the MHS services using docker containers follow the steps below:
- Make a file in the root call
export-env-vars-and-run-mhs-docker.sh
this name must match to be excluded from git - Populate the file with the following information:
#!/bin/bash
LIGHT_GREEN='\033[1;32m'
NC='\033[0m'
echo -e "${LIGHT_GREEN}Exporting environment variables${NC}"
# Your Party key here
export MHS_SECRET_PARTY_KEY=""
# Your endpoint certificate here
export MHS_SECRET_CLIENT_CERT=""
# Your endpoint private key here
export MHS_SECRET_CLIENT_KEY=""
# Endpoint issuing subCA certificate and Root CA certificate here
export MHS_SECRET_CA_CERTS=""
./start-mhs-docker-containers.sh
- Populate the environment variables with the certificate details received from NHS OpenTest
- Execute the script
export-env-vars-and-run-mhs-docker.sh