From d32b0a9e33857b4d1d57cabd8ad08dfe3596d28d Mon Sep 17 00:00:00 2001 From: Adrian Clay Date: Mon, 9 Sep 2024 09:36:33 +0100 Subject: [PATCH] Automate the adaptor release to Dockerhub process (#192) * Rename dockers folder to docker to be consistent with other adaptors This will be required when using the release-adaptor-container-image GitHub Actions workflow as it assumes the folder is called docker. * Move adaptor Dockerfiles into the docker folder This consolidates Dockerfiles into one place, keeping this adaptor directory layout consistent with other adaptors. This also allows us to use the release-adaptor-container-image GitHub Actions shared workflow. * Automate the adaptor release to Dockerhub process This should speed up and simplify the process of releasing --- .github/workflows/release.yml | 18 ++++++++++++++++++ Jenkinsfile | 6 +++--- README.md | 2 +- build.sh | 6 +++--- docker-compose.yml | 2 +- .../common/dynamodb-local/Dockerfile | 0 .../common/dynamodb-local/README.md | 0 .../common/dynamodb-local/VERSION | 0 .../common/dynamodb-local/release.sh | 0 {dockers => docker}/common/rabbitmq/Dockerfile | 0 {dockers => docker}/common/rabbitmq/README.md | 0 {dockers => docker}/common/rabbitmq/VERSION | 0 {dockers => docker}/common/rabbitmq/release.sh | 0 {mhs => docker}/inbound/Dockerfile | 0 {mhs => docker}/outbound/Dockerfile | 0 {dockers => docker}/sds-api-mock/Dockerfile | 0 .../sds-api-mock/stubs/__files/device.json | 0 .../sds-api-mock/stubs/__files/endpoint.json | 0 .../sds-api-mock/stubs/mappings/getDevice.json | 0 .../stubs/mappings/getEndpoint.json | 0 {mhs => docker}/spineroutelookup/Dockerfile | 0 mhs/mhs-adaptor-dev-notes.md | 14 ++------------ release-scripts/release.sh | 15 --------------- 23 files changed, 28 insertions(+), 35 deletions(-) create mode 100644 .github/workflows/release.yml rename {dockers => docker}/common/dynamodb-local/Dockerfile (100%) rename {dockers => docker}/common/dynamodb-local/README.md (100%) rename {dockers => docker}/common/dynamodb-local/VERSION (100%) rename {dockers => docker}/common/dynamodb-local/release.sh (100%) rename {dockers => docker}/common/rabbitmq/Dockerfile (100%) rename {dockers => docker}/common/rabbitmq/README.md (100%) rename {dockers => docker}/common/rabbitmq/VERSION (100%) rename {dockers => docker}/common/rabbitmq/release.sh (100%) rename {mhs => docker}/inbound/Dockerfile (100%) rename {mhs => docker}/outbound/Dockerfile (100%) rename {dockers => docker}/sds-api-mock/Dockerfile (100%) rename {dockers => docker}/sds-api-mock/stubs/__files/device.json (100%) rename {dockers => docker}/sds-api-mock/stubs/__files/endpoint.json (100%) rename {dockers => docker}/sds-api-mock/stubs/mappings/getDevice.json (100%) rename {dockers => docker}/sds-api-mock/stubs/mappings/getEndpoint.json (100%) rename {mhs => docker}/spineroutelookup/Dockerfile (100%) delete mode 100755 release-scripts/release.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..a55532e89 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,18 @@ +on: + push: + tags: "*" + +jobs: + push_to_dockerhub: + strategy: + matrix: + image: + - {folder: spineroutelookup, dockerhub_name: nia-mhs-route} + - {folder: outbound, dockerhub_name: nia-mhs-outbound} + - {folder: inbound, dockerhub_name: nia-mhs-inbound} + uses: NHSDigital/integration-adaptor-actions/.github/workflows/release-adaptor-container-image.yml@main + with: + dockerhub_name: ${{matrix.image.dockerhub_name}} + folder: ${{matrix.image.folder}} + + secrets: inherit diff --git a/Jenkinsfile b/Jenkinsfile index 2d228d111..b090dcfbb 100755 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -58,7 +58,7 @@ pipeline { expression { currentBuild.resultIsBetterOrEqualTo('SUCCESS') } } steps { - buildAndPushImage('${LOCAL_INBOUND_IMAGE_NAME}', '${INBOUND_IMAGE_NAME}', 'mhs/inbound/Dockerfile') + buildAndPushImage('${LOCAL_INBOUND_IMAGE_NAME}', '${INBOUND_IMAGE_NAME}', 'docker/inbound/Dockerfile') } } } @@ -84,7 +84,7 @@ pipeline { expression { currentBuild.resultIsBetterOrEqualTo('SUCCESS') } } steps { - buildAndPushImage('${LOCAL_OUTBOUND_IMAGE_NAME}', '${OUTBOUND_IMAGE_NAME}', 'mhs/outbound/Dockerfile') + buildAndPushImage('${LOCAL_OUTBOUND_IMAGE_NAME}', '${OUTBOUND_IMAGE_NAME}', 'docker/outbound/Dockerfile') } } } @@ -110,7 +110,7 @@ pipeline { expression { currentBuild.resultIsBetterOrEqualTo('SUCCESS') } } steps { - buildAndPushImage('${LOCAL_ROUTE_IMAGE_NAME}', '${ROUTE_IMAGE_NAME}', 'mhs/spineroutelookup/Dockerfile') + buildAndPushImage('${LOCAL_ROUTE_IMAGE_NAME}', '${ROUTE_IMAGE_NAME}', 'docker/spineroutelookup/Dockerfile') } } } diff --git a/README.md b/README.md index 14205874e..3cc8b447f 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ The following illustration shows the MHS adaptor in the wider systems context: ## Repository Contents This repository contains the following directories: - [common](common) - A Python package containing components and utilities that are common to several integration adaptors. -- [dockers](dockers) - Files used to create each of the base docker images that make up the MHS adaptor +- [docker](docker) - Files used to create each of the base docker images that make up the MHS adaptor - [documentation](documentation) - Documentation and assets for the integration adaptors including workflows and two architecture exemplars based on AWS and Azure - [integration-tests](integration-tests) - A package containing integration tests intended to pre-assure the MHS Adaptor - [mhs](mhs) - A pre-assured implementation of a Message Handling Service (MHS), that encapsulates the details of Spine diff --git a/build.sh b/build.sh index e2b4321bc..a2d170075 100755 --- a/build.sh +++ b/build.sh @@ -1,5 +1,5 @@ set -e BUILD_TAG="${BUILD_TAG:-latest}" -docker build -t local/mhs-inbound:${BUILD_TAG} -f mhs/inbound/Dockerfile . -docker build -t local/mhs-outbound:${BUILD_TAG} -f mhs/outbound/Dockerfile . -docker build -t local/mhs-route:${BUILD_TAG} -f mhs/spineroutelookup/Dockerfile . +docker build -t local/mhs-inbound:${BUILD_TAG} -f docker/inbound/Dockerfile . +docker build -t local/mhs-outbound:${BUILD_TAG} -f docker/outbound/Dockerfile . +docker build -t local/mhs-route:${BUILD_TAG} -f docker/spineroutelookup/Dockerfile . diff --git a/docker-compose.yml b/docker-compose.yml index 7cd88cd5a..8ec8238e0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -111,7 +111,7 @@ services: - TIMEOUT=connect 0, client 0, server 0 sds-api-mock: - build: ./dockers/sds-api-mock + build: ./docker/sds-api-mock ports: - "8081:8080" command: diff --git a/dockers/common/dynamodb-local/Dockerfile b/docker/common/dynamodb-local/Dockerfile similarity index 100% rename from dockers/common/dynamodb-local/Dockerfile rename to docker/common/dynamodb-local/Dockerfile diff --git a/dockers/common/dynamodb-local/README.md b/docker/common/dynamodb-local/README.md similarity index 100% rename from dockers/common/dynamodb-local/README.md rename to docker/common/dynamodb-local/README.md diff --git a/dockers/common/dynamodb-local/VERSION b/docker/common/dynamodb-local/VERSION similarity index 100% rename from dockers/common/dynamodb-local/VERSION rename to docker/common/dynamodb-local/VERSION diff --git a/dockers/common/dynamodb-local/release.sh b/docker/common/dynamodb-local/release.sh similarity index 100% rename from dockers/common/dynamodb-local/release.sh rename to docker/common/dynamodb-local/release.sh diff --git a/dockers/common/rabbitmq/Dockerfile b/docker/common/rabbitmq/Dockerfile similarity index 100% rename from dockers/common/rabbitmq/Dockerfile rename to docker/common/rabbitmq/Dockerfile diff --git a/dockers/common/rabbitmq/README.md b/docker/common/rabbitmq/README.md similarity index 100% rename from dockers/common/rabbitmq/README.md rename to docker/common/rabbitmq/README.md diff --git a/dockers/common/rabbitmq/VERSION b/docker/common/rabbitmq/VERSION similarity index 100% rename from dockers/common/rabbitmq/VERSION rename to docker/common/rabbitmq/VERSION diff --git a/dockers/common/rabbitmq/release.sh b/docker/common/rabbitmq/release.sh similarity index 100% rename from dockers/common/rabbitmq/release.sh rename to docker/common/rabbitmq/release.sh diff --git a/mhs/inbound/Dockerfile b/docker/inbound/Dockerfile similarity index 100% rename from mhs/inbound/Dockerfile rename to docker/inbound/Dockerfile diff --git a/mhs/outbound/Dockerfile b/docker/outbound/Dockerfile similarity index 100% rename from mhs/outbound/Dockerfile rename to docker/outbound/Dockerfile diff --git a/dockers/sds-api-mock/Dockerfile b/docker/sds-api-mock/Dockerfile similarity index 100% rename from dockers/sds-api-mock/Dockerfile rename to docker/sds-api-mock/Dockerfile diff --git a/dockers/sds-api-mock/stubs/__files/device.json b/docker/sds-api-mock/stubs/__files/device.json similarity index 100% rename from dockers/sds-api-mock/stubs/__files/device.json rename to docker/sds-api-mock/stubs/__files/device.json diff --git a/dockers/sds-api-mock/stubs/__files/endpoint.json b/docker/sds-api-mock/stubs/__files/endpoint.json similarity index 100% rename from dockers/sds-api-mock/stubs/__files/endpoint.json rename to docker/sds-api-mock/stubs/__files/endpoint.json diff --git a/dockers/sds-api-mock/stubs/mappings/getDevice.json b/docker/sds-api-mock/stubs/mappings/getDevice.json similarity index 100% rename from dockers/sds-api-mock/stubs/mappings/getDevice.json rename to docker/sds-api-mock/stubs/mappings/getDevice.json diff --git a/dockers/sds-api-mock/stubs/mappings/getEndpoint.json b/docker/sds-api-mock/stubs/mappings/getEndpoint.json similarity index 100% rename from dockers/sds-api-mock/stubs/mappings/getEndpoint.json rename to docker/sds-api-mock/stubs/mappings/getEndpoint.json diff --git a/mhs/spineroutelookup/Dockerfile b/docker/spineroutelookup/Dockerfile similarity index 100% rename from mhs/spineroutelookup/Dockerfile rename to docker/spineroutelookup/Dockerfile diff --git a/mhs/mhs-adaptor-dev-notes.md b/mhs/mhs-adaptor-dev-notes.md index 52537a320..49951982a 100644 --- a/mhs/mhs-adaptor-dev-notes.md +++ b/mhs/mhs-adaptor-dev-notes.md @@ -169,16 +169,6 @@ Make a note of the most recent Release within GitHub, and identify what the next Create a new release within GitHub, specifying the tag as the version to use (e.g. 1.2.9), and the target being the commit you identified. Click on the "Generate release notes" button and this will list all the current changes from the recent commit. +Click the "Publish release" button, this will start an automated GitHub Actions workflow to publish the images to Dockerhub for the new version. -CD into `released scripts` folder and update the `/release.sh`, changing the `BUILD_TAG` value to match the release created above. -Update the `CHANGELOG.md` file, copying the release information within the GitHub release. -Raise a PR for your changes. - -Once your changes have been merged, log into DockerHub using the credentials stored within our AWS accounts Secrets Manager, secret name `nhsdev-dockerhub-credentials` in London region. -Go to AWS Management Console > Secrets Manager then find the option 'retrieve keys'. - -If you have not created a release before then you will first need to create a new docker builder instance using `docker buildx create --use`. - -Execute `./release.sh`. - -Log out of DockerHub. +Update the `CHANGELOG.md` file, adding a new version header for all the changes being released. Raise a PR for your changes. diff --git a/release-scripts/release.sh b/release-scripts/release.sh deleted file mode 100755 index 366d75af3..000000000 --- a/release-scripts/release.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -set -e - -export BUILD_TAG=1.3.0 - -git fetch -git checkout $BUILD_TAG - -cd .. - -# These are buildx versions of what is inside of `build.sh` -docker buildx build -f mhs/inbound/Dockerfile . --platform linux/arm64/v8,linux/amd64 --tag nhsdev/nia-mhs-inbound:${BUILD_TAG} --push -docker buildx build -f mhs/outbound/Dockerfile . --platform linux/arm64/v8,linux/amd64 --tag nhsdev/nia-mhs-outbound:${BUILD_TAG} --push -docker buildx build -f mhs/spineroutelookup/Dockerfile . --platform linux/arm64/v8,linux/amd64 --tag nhsdev/nia-mhs-route:${BUILD_TAG} --push \ No newline at end of file