Skip to content

Running the Data API

Bogdan Marc edited this page Sep 6, 2024 · 1 revision

The application connects to the triple store via a data-api service.

The easiest way to do this is as a local docker container. The image can be built from lr-data-api repository. or pulled from Amazon Elastic Container Registry ECR

Building and running from lr-data-api repository

To build and a run a new docker image check out the lr-data-api repository and run

make image run

Running an existing ECR image

Obtaining an ECR image requires:

  • AWS IAM credentials to connect to the HMLR AWS account
  • the ECR credentials helper installed locally (see here)
  • Set the contents of your ~/.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[^1], 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"
  }
}

Once you have a local copy of the required image, it is advisable to run a local docker bridge network to mirror production and development environments.

Running a client application as a docker image from their respective Makefiles will set this up automatically, but to confirm run

docker network inspect dnet

To create the docker network run

docker network create dnet

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.