Skip to content

Commit 27bfd3c

Browse files
authored
Merge pull request #27 from NHSDigital/bugfix/fix-specification-build-for-sandbox-and-test
Bugfix/fix specification build for sandbox and test
2 parents 88c8a25 + 88038c1 commit 27bfd3c

File tree

9 files changed

+55
-22
lines changed

9 files changed

+55
-22
lines changed

Makefile

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ set-ratelimit: guard-APIM_ENV
112112
< specification/x-nhsd-apim/ratelimit-template.yaml > specification/x-nhsd-apim/ratelimit.yaml
113113

114114
update-spec-template: guard-APIM_ENV
115-
ifeq ($(APIM_ENV), $(filter $(APIM_ENV), sandbox internal-dev int ref preprod prod ))
115+
ifeq ($(APIM_ENV), $(filter $(APIM_ENV), sandbox internal-dev test int ref preprod prod ))
116116
@ $(MAKE) set-target APIM_ENV=$$APIM_ENV
117117
@ $(MAKE) set-access APIM_ENV=$$APIM_ENV
118118
@ $(MAKE) set-security APIM_ENV=$$APIM_ENV
@@ -123,10 +123,15 @@ else
123123
endif
124124

125125
construct-spec: guard-APIM_ENV
126-
@ $(MAKE) update-spec-template APIM_ENV=$$APIM_ENV
127-
mkdir -p build/specification/$(APIM_ENV) && \
128-
npx redocly bundle specification/eligibility-signposting-api.yaml --remove-unused-components --keep-url-references --ext yaml \
129-
> build/specification/$(APIM_ENV)/eligibility-signposting-api.yaml
126+
@ $(MAKE) update-spec-template APIM_ENV=$$APIM_ENV
127+
mkdir -p build/specification/$(APIM_ENV)
128+
ifeq ($(APIM_ENV), sandbox)
129+
sed '/^[[:space:]]*security:/,/^[[:space:]]*-[[:space:]]/c\ security:\n - app-level0: []' specification/eligibility-signposting-api.yaml > specification/eligibility-signposting-api.generated.yaml && \
130+
npx redocly bundle specification/eligibility-signposting-api.generated.yaml --remove-unused-components --keep-url-references --ext yaml > build/specification/$(APIM_ENV)/eligibility-signposting-api.yaml
131+
rm specification/eligibility-signposting-api.generated.yaml
132+
else
133+
npx redocly bundle specification/eligibility-signposting-api.yaml --remove-unused-components --keep-url-references --ext yaml > build/specification/$(APIM_ENV)/eligibility-signposting-api.yaml
134+
endif
130135

131136

132137
SPEC_DIR := $(CURDIR)/specification

sandbox/Makefile

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,42 @@ list:
66
@grep '^[^#[:space:]].*:' Makefile
77

88
build:
9-
docker-compose -f docker-compose.yaml build
9+
docker compose -f docker-compose.yaml build
10+
11+
tag-service-image:
12+
$(eval IMAGE_ID=$(shell docker images -q sandbox-combined-service:latest))
13+
@if [ -z "$(IMAGE_ID)" ]; then \
14+
echo "ERROR: No image ID found for sandbox-combined-service:latest. Did you build it?"; \
15+
exit 1; \
16+
fi
17+
docker tag $(IMAGE_ID) 958002497996.dkr.ecr.eu-west-2.amazonaws.com/eligibility-signposting-api:latest
18+
@echo "Tagged image $(IMAGE_ID) as 958002497996.dkr.ecr.eu-west-2.amazonaws.com/eligibility-signposting-api:latest"
19+
20+
build-and-tag:
21+
make build
22+
make tag-service-image
23+
24+
proxygen-docker-login: # Login to Proxygen Docker registry
25+
make -C .. setup-proxygen-credentials
26+
proxygen docker get-login | bash
27+
28+
publish-to-docker-repo:
29+
proxygen-docker-login
30+
docker push 958002497996.dkr.ecr.eu-west-2.amazonaws.com/eligibility-signposting-api:latest
31+
32+
build-and-publish-sandbox-image:
33+
make build-and-tag
34+
make publish-to-docker-repo
35+
36+
deploy-sandbox-spec:
37+
make -C .. construct-spec APIM_ENV=sandbox
38+
proxygen instance deploy sandbox eligibility-signposting-api ./build/specification/sandbox/eligibility-signposting-api.yaml
1039

1140
up: build
12-
docker-compose -f docker-compose.yaml up -d
41+
docker compose -f docker-compose.yaml up -d
1342

1443
down:
15-
docker-compose -f docker-compose.yaml down
44+
docker compose -f docker-compose.yaml down
1645

1746
clean:
1847
rm -rf ./node_modules

sandbox/README.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,5 @@ Instructions for creation and deployment of the sandbox specification can be fou
6565
6666
To deploy the sandbox Docker image to AWS ECR, we use Proxygen CLI as follows:
6767
68-
1. Follow the instructions in the [specification README](/specification/README.md) to set up Proxygen authentication.
69-
2. Run `proxygen docker get-login` and copy the command provided in the response.
70-
3. Run the command to authenticate with our ECR repository.
71-
4. Build the sandbox container - `make build` in this directory.
72-
5. Tag the image created using `docker image tag <image id> 958002497996.dkr.ecr.eu-west-2.amazonaws.com/eligibility-signposting-api:latest`. You
73-
can see what the image id is by running `docker images` to find what was just built.
74-
6. Push the docker image to our ECR repository using `docker push 958002497996.dkr.ecr.eu-west-2.amazonaws.com/eligibility-signposting-api:latest`
68+
1. Run `make build-and-publish-sandbox-image` to build the sandbox image and publish to the docker ECR repository.
69+
2. Run `make deploy-sandbox-spec` to build and publish the sandbox spec to the sandbox instance on APIM.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
$ref: https://proxygen.prod.api.platform.nhs.uk/components/securitySchemes/nhs-login-p9
1+
nhs-login-p9:
2+
$ref: https://proxygen.prod.api.platform.nhs.uk/components/securitySchemes/nhs-login-p9
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
$ref: https://proxygen.prod.api.platform.nhs.uk/components/securitySchemes/nhs-login-p9
1+
nhs-login-p9:
2+
$ref: https://proxygen.prod.api.platform.nhs.uk/components/securitySchemes/nhs-login-p9
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
$ref: https://proxygen.prod.api.platform.nhs.uk/components/securitySchemes/nhs-login-p9
1+
nhs-login-p9:
2+
$ref: https://proxygen.prod.api.platform.nhs.uk/components/securitySchemes/nhs-login-p9
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
$ref: https://proxygen.prod.api.platform.nhs.uk/components/securitySchemes/app-level0
1+
app-level0:
2+
$ref: https://proxygen.prod.api.platform.nhs.uk/components/securitySchemes/app-level0
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
$ref: https://proxygen.prod.api.platform.nhs.uk/components/securitySchemes/nhs-login-p9
1+
nhs-login-p9:
2+
$ref: https://proxygen.prod.api.platform.nhs.uk/components/securitySchemes/nhs-login-p9

specification/eligibility-signposting-api.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ paths:
2525
Determines which suggestions a person is eligible for and which they are
2626
not, including reasons and next steps.
2727
security:
28-
- environment-specific-secured: []
28+
- nhs-login-p9: []
2929
operationId: checkEligibility
3030
parameters:
3131
- name: id
@@ -766,7 +766,6 @@ paths:
766766
################################################################################
767767
components:
768768
securitySchemes:
769-
environment-specific-secured:
770769
$ref: "components/security/security.yaml"
771770
x-nhsd-apim:
772771
access:

0 commit comments

Comments
 (0)