-
Notifications
You must be signed in to change notification settings - Fork 1
Part 1: Build docker images and push it to ECR
Building the docker images (web & api) and pushing them to the AWS ECR is now done through GitHub Actions. Follow the bullet points below this image to build the docker images and push to ECR.
Part 1, build once and store the image in ECR on the DS-intersite account and Part 2, deploy the same image to Dev/Test/Live environment.
Run the 'KBS Build and Push API & Web' workflow to build the docker images (web & api) and push them to the AWS ECR
- i. Raise a PR and get your code change approved and merged into
main
. - ii. Click on the 'Actions' menu item on https://github.com/nationalarchives/ds-book-a-reading-room-visit.
- iii. Click on the 'KBS Build and Push API & Web' workflow button on the left hand menu.
- iv. Expand 'Run workflow' dropdown on the right under workflow runs on the main page.
- v. Select the Web and/or the API checkbox depending on what you are deploying.
- vi. Enter the build image version as the version Tag. (Get the current version numbers from the AWS console (DS-Intersite London ECR) or the web.yaml and api.yaml in the Terraform repo environment cluster and increment by 1.)
- vii. Run the workflow.
Goto Part 2 Connecting to an existing Kubernetes cluster
Steps 1 to 6 below are now superseded by using the 'KBS Build and Push API & Web' GitHub Action to perform them
Open the power-shell as administrator and navigate to your kbs solution directory on your machine (e.g. cd C:\Repos\ds-book-a-reading-room-visit) and get the latest code from GitHub
`git checkout main'
'git pull'
Run the below code, change the version number with subsequent number (refer the ECR on DS-intersite ECR-->Repositories-->kbs-web to find the current image tag and increment by 1). Make sure you include the fullstop at the end of the command otherwise you will get a '"docker build" requires exactly 1 argument'.
docker build -t 500447081210.dkr.ecr.eu-west-2.amazonaws.com/kbs-web:<version> -f Dockerfile-web .
If you get a message 'error during connect: In the default daemon configuration on Windows, the docker client must be run with elevated privileges to connect.' make sure you have Docker running on your machine.
Run the below code, change the version number with subsequent number (refer the ECR on DS-intersite ECR-->Repositories-->kbs-api to find the current image tag and increment by 1). Make sure you include the fullstop at the end of the command otherwise you will get a '"docker build" requires exactly 1 argument'.
docker build -t 500447081210.dkr.ecr.eu-west-2.amazonaws.com/kbs-api:<version> -f Dockerfile-api .
If you get a message 'error during connect: In the default daemon configuration on Windows, the docker client must be run with elevated privileges to connect.' make sure you have Docker running on your machine.
Run the below code, replacing with your aws.credentials profile name for the DS-intersite (500447081210) account. (You do not have to change the username and password in the command.)
aws ecr get-login-password --region eu-west-2 --profile <inter-site-profile-account> | docker login --username AWS --password-stdin 500447081210.dkr.ecr.eu-west-2.amazonaws.com
Run the below code, change the version number with the build image version
docker push 500447081210.dkr.ecr.eu-west-2.amazonaws.com/kbs-web:<version>
Run the below code, change the version number with the build image version
docker push 500447081210.dkr.ecr.eu-west-2.amazonaws.com/kbs-api:<version>