Skip to content

communitiesuk/epb-register-api

Repository files navigation

epb-register-api

Prerequisites

Installing

bundle install

Creating a local database

Ensure you have Postgres 11 installed. If you are working on a Mac, this tutorial will take you through the process.

You will need to have a user with the role name postgres, which has the Create DB and Superuser permissions to create databases and install the fuzzystrmatch extension.

Once you have set this up, run the command to set up and seed your local database

make seed-local-db

You will need to set the following environment variables

export STAGE=test

Set the endpoint of unleash to be any valid URL. You will need to run your own local version of unleash if you want to use feature toggles.

export EPB_UNLEASH_URI=https://google.com

To decode and validate JWTs passed in to the API the environment variables JWT_ISSUER and JWT_SECRET need to be set. The values for these should match those on the auth server being connected to.

export JWT_ISSUER=dev.issuer export JWT_SECRET=dev.secret

Running tests

make test

Running server

make run

This will make the API available at http://localhost:9191.

Code Formatting

To run Rubocop:

make format

CI

Build commands are stored in the buildspec directory

Docker image

Build

The codebase contains a dockerfile for the api

To rebuild the api Docker image locally, run

docker build . --tag epb-register-api

Run

Docker Desktop

You can run the created image in Docker Desktop by going to Images and pressing Run in the Actions column. This will create a persistent deployment and has an interface to provide multiple useful options.

CLI

API Service

docker run -p {host_port}:80 -p {host_port2}:443 --name test-epb-register-api epb-register-api

Where host_port is a free port you want to use on your host machine to make calls to the API.

Communicating with other containers

When running the containers, you may want them to communicate with a containerized instance of PostgreSQL, Redis, or another container in general. To do this, you will need to use a bridge network and connect any containers that need to communicate with each other to it

You can set up a bridge network using docker network create {network_name}

And then connect the containers to the network when going to run them e.g.

  • for the api docker run -p {host_port}:80 -p {host_port2}:443 --network {network_name} --name test-epb-register-api epb-register-api

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages