Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PI-2377 Combine Prism mocks into a single Dockerfile #465

Merged
merged 1 commit into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions Dockerfile.adjudications-api

This file was deleted.

10 changes: 10 additions & 0 deletions Dockerfile.prism
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM stoplight/prism:5

COPY src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/prismMocks /prismMocks
ADD https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/projects/external-api-and-delius/api-docs.json /prismMocks/ndelius.json
ADD https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/projects/effective-proposal-framework-and-delius/api-docs.json /prismMocks/probation-integration-epf.json
ADD https://dev.moic.service.justice.gov.uk/v3/api-docs.json /prismMocks/manage-pom-case-api.json

RUN sed -i 's/\*\/\*/application\/json/g' /prismMocks/prisoner-offender-search.json

ENTRYPOINT sh -c 'port=4010; for file in $(ls /prismMocks/*.json | sort); do node dist/index.js mock -p $port -h 0.0.0.0 $file & port=$((port + 1)); done; wait'
13 changes: 0 additions & 13 deletions Dockerfile.setup-assess-risks-and-needs-api

This file was deleted.

14 changes: 0 additions & 14 deletions Dockerfile.setup-case-notes-api

This file was deleted.

13 changes: 0 additions & 13 deletions Dockerfile.setup-create-and-vary-a-licence-api

This file was deleted.

12 changes: 0 additions & 12 deletions Dockerfile.setup-manage-pom-case-api

This file was deleted.

12 changes: 0 additions & 12 deletions Dockerfile.setup-ndelius-api

This file was deleted.

13 changes: 0 additions & 13 deletions Dockerfile.setup-prison-api

This file was deleted.

13 changes: 0 additions & 13 deletions Dockerfile.setup-prisoner-search

This file was deleted.

12 changes: 0 additions & 12 deletions Dockerfile.setup-probation-integration-epf-api

This file was deleted.

12 changes: 0 additions & 12 deletions Dockerfile.setup-probation-offender-search

This file was deleted.

14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,18 @@ make serve
Each service is then accessible at:

- [http://localhost:8080](http://localhost:8080) for this application
- [http://localhost:4030](http://localhost:4030) for the Prison API
- [http://localhost:4040](http://localhost:4040) for the ndelius API
- [http://localhost:4020](http://localhost:4020) for the Probation Offender Search
- [http://localhost:4010](http://localhost:4010) for the Prisoner Search
- [http://localhost:4010](http://localhost:4010) to [http://localhost:40XX]() for mocked HMPPS APIs
- [http://localhost:9090](http://localhost:9090) for the HMPPS Auth service

To call the integration-api, you need to pass a distinguished name in the `subject-distinguished-name` header. The `CN` attribute should match the client you wish to access the service as.
The list of clients and their authorised endpoints can be found in [application-local-docker.yml](src/main/resources/application-local-docker.yml).

For example,

```bash
curl -H "subject-distinguished-name: O=local,CN=all-access" http://localhost:8080/health
```

As part of getting the HMPPS Auth service running
locally, [the in-memory database is seeded with data including a number of clients](https://github.com/ministryofjustice/hmpps-auth/blob/main/src/main/resources/db/dev/data/auth/V900_0__clients.sql). A client can have different permissions i.e. read, write, reporting, although strangely the column name is called `​​autoapprove`.

Expand Down
126 changes: 17 additions & 109 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
version: "3.9"
services:
hmpps-integration-api:
build:
context: .
container_name: hmpps-integration-api
ports:
- "8080:8080"
healthcheck:
test: [ "CMD", "echo", "1" ]
test: [ "CMD", "curl", "-f", "http://localhost:8080/health" ]
depends_on:
prison-api:
condition: service_healthy
prisoner-search:
condition: service_healthy
probation-offender-search:
condition: service_healthy
probation-integration-epf-api:
condition: service_healthy
manage-pom-case-api:
hmpps-auth:
condition: service_healthy
ports:
- "8080:8080"
environment:
- SERVER_PORT=8080
- SPRING_PROFILES_ACTIVE=local-docker
Expand All @@ -36,105 +27,22 @@ services:
- SPRING_PROFILES_ACTIVE=dev
- LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_WEB=TRACE

ndelius-api:
build:
context: .
dockerfile: Dockerfile.setup-ndelius-api
container_name: ndelius-api
healthcheck:
test: 'wget --header="Authorization: Bearer abc" http://127.0.0.1:4010/case/abc/supervisions -O /dev/null'
ports:
- '4040:4010'

prison-api:
build:
context: .
dockerfile: Dockerfile.setup-prison-api
container_name: prison-api
healthcheck:
test: 'wget --header="Authorization: Bearer abc" http://127.0.0.1:4010/api/offenders/A1234AL -O /dev/null'
ports:
- '4030:4010'

prisoner-search:
build:
context: .
dockerfile: Dockerfile.setup-prisoner-search
container_name: prisoner-search
healthcheck:
test: 'wget --header="Authorization: Bearer abc" http://0.0.0.0:4010/prisoner/nemo -O /dev/null'
ports:
- "4010:4010"

probation-offender-search:
build:
context: .
dockerfile: Dockerfile.setup-probation-offender-search
container_name: probation-offender-search
healthcheck:
test: 'wget --header="Authorization: Bearer abc" http://0.0.0.0:4010/search?crn=sit -O /dev/null'
ports:
- '4020:4010'

assess-risks-and-needs-api:
build:
context: .
dockerfile: Dockerfile.setup-assess-risks-and-needs-api
container_name: assess-risks-and-needs-api
healthcheck:
test: 'wget --header="Authorization: Bearer abc" http://0.0.0.0:4010/risks/crn/abc/predictors/all -O /dev/null'
ports:
- '4050:4010'

probation-integration-epf-api:
build:
context: .
dockerfile: Dockerfile.setup-probation-integration-epf-api
container_name: probation-integration-epf-api
healthcheck:
test: 'wget --header="Authorization: Bearer abc" http://0.0.0.0:4010/case-details/crn/1234 -O /dev/null'
ports:
- '4060:4010'

adjudications-api:
prism:
build:
context: .
dockerfile: Dockerfile.adjudications-api
container_name: adjudications-api
healthcheck:
test: 'wget --header="Authorization: Bearer abc" http://0.0.0.0:4010/reported-adjudications/hearings?hearingDate=1916-07-16 -O /dev/null'
ports:
- '4045:4010'

create-and-vary-licence-api:
build:
context: .
dockerfile: Dockerfile.setup-create-and-vary-a-licence-api
container_name: create-and-vary-licence-api
healthcheck:
test: 'wget --header="Authorization: Bearer abc" http://0.0.0.0:4010/public/licences/id/123 -O /dev/null'
ports:
- '4070:4010'

case-notes-api:
build:
context: .
dockerfile: Dockerfile.setup-case-notes-api
container_name: case-notes-api
healthcheck:
test: 'wget --header="Authorization: Bearer abc" http://0.0.0.0:4010/case-notes/1234 -O /dev/null'
ports:
- '4080:4010'

manage-pom-case-api:
build:
context: .
dockerfile: Dockerfile.setup-manage-pom-case-api
container_name: manage-pom-case-api
healthcheck:
test: 'wget --header="Authorization: Bearer abc" http://127.0.0.1:4010/api/allocation/X1234YZ/primary_pom -O /dev/null'
dockerfile: Dockerfile.prism
container_name: prism
ports:
- '4090:4010'
- '4010:4010'
- '4011:4011'
- '4012:4012'
- '4013:4013'
- '4014:4014'
- '4015:4015'
- '4016:4016'
- '4017:4017'
- '4018:4018'
- '4019:4019'

local-stack-aws:
image: localstack/localstack:3.0
Expand Down
36 changes: 14 additions & 22 deletions src/main/resources/application-local-docker.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,16 @@
services:
probation-offender-search:
base-url: http://probation-offender-search:4010
prisoner-offender-search:
base-url: http://prisoner-search:4010
prison-api:
base-url: http://prison-api:4010
ndelius:
base-url: http://ndelius-api:4010
assess-risks-and-needs:
base-url: http://assess-risks-and-needs-api:4010
probation-integration-epf:
base-url: http://probation-integration-epf-api:4010
adjudications:
base-url: http://adjudications-api:4010
create-and-vary-licence:
base-url: http://create-and-vary-licence-api:4010
case-notes:
base-url: http://case-notes-api:4010
manage-pom-case-api:
base-url: http://manage-pom-case-api:4010
hmpps-auth:
base-url: http://hmpps-auth:8080
hmpps-auth.base-url: http://hmpps-auth:8080

adjudications.base-url: http://prism:4010
assess-risks-and-needs.base-url: http://prism:4011
case-notes.base-url: http://prism:4012
create-and-vary-licence.base-url: http://prism:4013
manage-pom-case-api.base-url: http://prism:4014
ndelius.base-url: http://prism:4015
prison-api.base-url: http://prism:4016
prisoner-offender-search.base-url: http://prism:4017
probation-integration-epf.base-url: http://prism:4018
probation-offender-search.base-url: http://prism:4019

authorisation:
consumers:
Expand Down Expand Up @@ -60,6 +50,8 @@ authorisation:
- "/info"
config-test:
- "/v1/config/authorisation"
all-access:
- "/.*"

hmpps.sqs:
provider: localstack
Expand Down
Loading
Loading