-
Notifications
You must be signed in to change notification settings - Fork 2
Running the Data API
The application communicates with the HMLR data API (which uses Sapi-NT) to
provide the data to be displayed. The actual API location is specified by the
environment variable API_SERVICE_URL
.
When developing UKHPI locally, it is necessary to have a dev instance of the API available. Since, for operations reasons, the actual service URL is not exposed to the open internet, you will need to run a local instance of the service.
This follows the same pattern as the PPD app, and developers can run a Docker container that defines the SapiNT API directly from the AWS Docker registry. To do this, you will need:
- AWS IAM credentials to connect to the HMLR AWS account
- the ECR credentials helper installed locally (see here)
- Setting the contents of your
{HOME}/.docker/config.json
file to be:
{
"credsStore": "ecr-login"
}
This configures the Docker daemon to use the credential helper for all Amazon ECR registries.
To use a credential helper for a specific ECR registry, create a
credHelpers
section with the URI of your ECR registry:
{
[...]
"credHelpers": {
"public.ecr.aws": "ecr-login",
"018852084843.dkr.ecr.eu-west-1.amazonaws.com": "ecr-login"
}
}
The local application can then connect to the triple store via the data-api
service.
The easiest way to do this is via a local docker container. The data-api
image
can be built from lr-data-api
repository. or pulled from Amazon
Elastic Container Registry
ECR
Once you have a local copy of the required data-api
image, to run the Data API
as a docker container:
docker run --network dnet -p 8888:8080 --rm --name data-api \
-e SERVER_DATASOURCE_ENDPOINT=https://landregistry.data.gov.uk/landregistry/query \
018852084843.dkr.ecr.eu-west-1.amazonaws.com/epimorphics/lr-data-api/dev:1.0-SNAPSHOT_a5590d2
Which then should produce something like:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.2.0.RELEASE)
{"ts":"2022-03-21T16:12:26.585Z","version":"1","logger_name":"com.epimorphics.SapiNtApplicationKt",
"thread_name":"main","level":"INFO","level_value":20000,
"message":"No active profile set, falling back to default profiles: default"}
The latest images can be found here for dev and production.
The identity of the Docker image will change periodically so the full list of versions can be found at AWS ECR
N.B. Port 8080 should be avoided to allow for a reverse proxy to run on this port.
With this set up, the api service is available on http://localhost:8888
from
the host or http://data-api:8080
from inside other docker containers.
Note: It is advisable to run a local docker bridge network to mirror production and development environments.
Running an HMLR application as a docker image from the respective Makefile
will set up the local docker bridge network automatically, but to confirm this
run:
docker network inspect dnet
If needed, to create the docker network run:
docker network create dnet