Skip to content

Commit 40e2f7f

Browse files
committed
PI-2377 Combine Prism mocks into a single Dockerfile
Also added a note to the README about how to call the API locally.
1 parent 9bb0ddf commit 40e2f7f

20 files changed

+68
-286
lines changed

Dockerfile.adjudications-api

-15
This file was deleted.

Dockerfile.prism

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM stoplight/prism:5
2+
3+
COPY src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/prismMocks /prismMocks
4+
ADD https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/projects/external-api-and-delius/api-docs.json /prismMocks/ndelius.json
5+
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
6+
ADD https://dev.moic.service.justice.gov.uk/v3/api-docs.json /prismMocks/manage-pom-case-api.json
7+
8+
RUN sed -i 's/\*\/\*/application\/json/g' /prismMocks/prisoner-offender-search.json
9+
10+
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'

Dockerfile.setup-assess-risks-and-needs-api

-13
This file was deleted.

Dockerfile.setup-case-notes-api

-14
This file was deleted.

Dockerfile.setup-create-and-vary-a-licence-api

-13
This file was deleted.

Dockerfile.setup-manage-pom-case-api

-12
This file was deleted.

Dockerfile.setup-ndelius-api

-12
This file was deleted.

Dockerfile.setup-prison-api

-13
This file was deleted.

Dockerfile.setup-prisoner-search

-13
This file was deleted.

Dockerfile.setup-probation-integration-epf-api

-12
This file was deleted.

Dockerfile.setup-probation-offender-search

-12
This file was deleted.

README.md

+10-4
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,18 @@ make serve
123123
Each service is then accessible at:
124124

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

129+
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.
130+
The list of clients and their authorised endpoints can be found in [application-local-docker.yml](src/main/resources/application-local-docker.yml).
131+
132+
For example,
133+
134+
```bash
135+
curl -H "subject-distinguished-name: O=local,CN=all-access" http://localhost:8080/health
136+
```
137+
132138
As part of getting the HMPPS Auth service running
133139
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`.
134140

docker-compose.yml

+17-109
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,15 @@
1-
version: "3.9"
21
services:
32
hmpps-integration-api:
43
build:
54
context: .
65
container_name: hmpps-integration-api
7-
ports:
8-
- "8080:8080"
96
healthcheck:
10-
test: [ "CMD", "echo", "1" ]
7+
test: [ "CMD", "curl", "-f", "http://localhost:8080/health" ]
118
depends_on:
12-
prison-api:
13-
condition: service_healthy
14-
prisoner-search:
15-
condition: service_healthy
16-
probation-offender-search:
17-
condition: service_healthy
18-
probation-integration-epf-api:
19-
condition: service_healthy
20-
manage-pom-case-api:
9+
hmpps-auth:
2110
condition: service_healthy
11+
ports:
12+
- "8080:8080"
2213
environment:
2314
- SERVER_PORT=8080
2415
- SPRING_PROFILES_ACTIVE=local-docker
@@ -36,105 +27,22 @@ services:
3627
- SPRING_PROFILES_ACTIVE=dev
3728
- LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_WEB=TRACE
3829

39-
ndelius-api:
40-
build:
41-
context: .
42-
dockerfile: Dockerfile.setup-ndelius-api
43-
container_name: ndelius-api
44-
healthcheck:
45-
test: 'wget --header="Authorization: Bearer abc" http://127.0.0.1:4010/case/abc/supervisions -O /dev/null'
46-
ports:
47-
- '4040:4010'
48-
49-
prison-api:
50-
build:
51-
context: .
52-
dockerfile: Dockerfile.setup-prison-api
53-
container_name: prison-api
54-
healthcheck:
55-
test: 'wget --header="Authorization: Bearer abc" http://127.0.0.1:4010/api/offenders/A1234AL -O /dev/null'
56-
ports:
57-
- '4030:4010'
58-
59-
prisoner-search:
60-
build:
61-
context: .
62-
dockerfile: Dockerfile.setup-prisoner-search
63-
container_name: prisoner-search
64-
healthcheck:
65-
test: 'wget --header="Authorization: Bearer abc" http://0.0.0.0:4010/prisoner/nemo -O /dev/null'
66-
ports:
67-
- "4010:4010"
68-
69-
probation-offender-search:
70-
build:
71-
context: .
72-
dockerfile: Dockerfile.setup-probation-offender-search
73-
container_name: probation-offender-search
74-
healthcheck:
75-
test: 'wget --header="Authorization: Bearer abc" http://0.0.0.0:4010/search?crn=sit -O /dev/null'
76-
ports:
77-
- '4020:4010'
78-
79-
assess-risks-and-needs-api:
80-
build:
81-
context: .
82-
dockerfile: Dockerfile.setup-assess-risks-and-needs-api
83-
container_name: assess-risks-and-needs-api
84-
healthcheck:
85-
test: 'wget --header="Authorization: Bearer abc" http://0.0.0.0:4010/risks/crn/abc/predictors/all -O /dev/null'
86-
ports:
87-
- '4050:4010'
88-
89-
probation-integration-epf-api:
90-
build:
91-
context: .
92-
dockerfile: Dockerfile.setup-probation-integration-epf-api
93-
container_name: probation-integration-epf-api
94-
healthcheck:
95-
test: 'wget --header="Authorization: Bearer abc" http://0.0.0.0:4010/case-details/crn/1234 -O /dev/null'
96-
ports:
97-
- '4060:4010'
98-
99-
adjudications-api:
30+
prism:
10031
build:
10132
context: .
102-
dockerfile: Dockerfile.adjudications-api
103-
container_name: adjudications-api
104-
healthcheck:
105-
test: 'wget --header="Authorization: Bearer abc" http://0.0.0.0:4010/reported-adjudications/hearings?hearingDate=1916-07-16 -O /dev/null'
106-
ports:
107-
- '4045:4010'
108-
109-
create-and-vary-licence-api:
110-
build:
111-
context: .
112-
dockerfile: Dockerfile.setup-create-and-vary-a-licence-api
113-
container_name: create-and-vary-licence-api
114-
healthcheck:
115-
test: 'wget --header="Authorization: Bearer abc" http://0.0.0.0:4010/public/licences/id/123 -O /dev/null'
116-
ports:
117-
- '4070:4010'
118-
119-
case-notes-api:
120-
build:
121-
context: .
122-
dockerfile: Dockerfile.setup-case-notes-api
123-
container_name: case-notes-api
124-
healthcheck:
125-
test: 'wget --header="Authorization: Bearer abc" http://0.0.0.0:4010/case-notes/1234 -O /dev/null'
126-
ports:
127-
- '4080:4010'
128-
129-
manage-pom-case-api:
130-
build:
131-
context: .
132-
dockerfile: Dockerfile.setup-manage-pom-case-api
133-
container_name: manage-pom-case-api
134-
healthcheck:
135-
test: 'wget --header="Authorization: Bearer abc" http://127.0.0.1:4010/api/allocation/X1234YZ/primary_pom -O /dev/null'
33+
dockerfile: Dockerfile.prism
34+
container_name: prism
13635
ports:
137-
- '4090:4010'
36+
- '4010:4010'
37+
- '4011:4011'
38+
- '4012:4012'
39+
- '4013:4013'
40+
- '4014:4014'
41+
- '4015:4015'
42+
- '4016:4016'
43+
- '4017:4017'
44+
- '4018:4018'
45+
- '4019:4019'
13846

13947
local-stack-aws:
14048
image: localstack/localstack:3.0

src/main/resources/application-local-docker.yml

+14-22
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,16 @@
11
services:
2-
probation-offender-search:
3-
base-url: http://probation-offender-search:4010
4-
prisoner-offender-search:
5-
base-url: http://prisoner-search:4010
6-
prison-api:
7-
base-url: http://prison-api:4010
8-
ndelius:
9-
base-url: http://ndelius-api:4010
10-
assess-risks-and-needs:
11-
base-url: http://assess-risks-and-needs-api:4010
12-
probation-integration-epf:
13-
base-url: http://probation-integration-epf-api:4010
14-
adjudications:
15-
base-url: http://adjudications-api:4010
16-
create-and-vary-licence:
17-
base-url: http://create-and-vary-licence-api:4010
18-
case-notes:
19-
base-url: http://case-notes-api:4010
20-
manage-pom-case-api:
21-
base-url: http://manage-pom-case-api:4010
22-
hmpps-auth:
23-
base-url: http://hmpps-auth:8080
2+
hmpps-auth.base-url: http://hmpps-auth:8080
3+
4+
adjudications.base-url: http://prism:4010
5+
assess-risks-and-needs.base-url: http://prism:4011
6+
case-notes.base-url: http://prism:4012
7+
create-and-vary-licence.base-url: http://prism:4013
8+
manage-pom-case-api.base-url: http://prism:4014
9+
ndelius.base-url: http://prism:4015
10+
prison-api.base-url: http://prism:4016
11+
prisoner-offender-search.base-url: http://prism:4017
12+
probation-integration-epf.base-url: http://prism:4018
13+
probation-offender-search.base-url: http://prism:4019
2414

2515
authorisation:
2616
consumers:
@@ -60,6 +50,8 @@ authorisation:
6050
- "/info"
6151
config-test:
6252
- "/v1/config/authorisation"
53+
all-access:
54+
- "/.*"
6355

6456
hmpps.sqs:
6557
provider: localstack

0 commit comments

Comments
 (0)