Skip to content

feat: docker build for multi arch #238

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

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft
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
137 changes: 61 additions & 76 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -317,11 +317,29 @@ jobs:
executor: default-machine
steps:
- checkout
- run:
name: Setup buildx and qemu
command: |
sudo apt-get update
sudo apt-get install -y qemu-user-static
sudo apt-get install -y binfmt-support
- run:
name: Check versions
command: |
qemu-aarch64-static --version
update-binfmts --version
- run:
name: Login to Docker Hub
command: docker login -u $DOCKER_USER -p $DOCKER_PASS
- run:
name: Build Docker local image
command: |
export DOCKER_CLI_EXPERIMENTAL=enabled
docker buildx create --name multi-arch-builder
docker buildx use multi-arch-builder
docker buildx inspect --bootstrap
echo "Building Docker image: local"
docker build -t $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:local .
docker buildx build --platform linux/amd64 --load -t $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:local .
- run:
name: Save docker image to workspace
command: docker save -o /tmp/docker-image-local.tar $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:local
Expand All @@ -330,40 +348,19 @@ jobs:
paths:
- ./docker-image-local.tar

build:
executor: default-machine
steps:
- attach_workspace:
at: /tmp
- run:
name: Load the pre-built docker local image from workspace
command: docker load -i /tmp/docker-image-local.tar
- run:
name: Re-tag the image
command: |
echo "Re-tagging Docker image: $CIRCLE_TAG"
docker tag $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:local $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$CIRCLE_TAG
- run:
name: Save the new docker image to workspace
command: docker save -o /tmp/docker-image.tar $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$CIRCLE_TAG
- persist_to_workspace:
root: /tmp
paths:
- ./docker-image.tar

license-scan:
executor: default-machine
steps:
- attach_workspace:
at: /tmp
- run:
name: Load the pre-built docker image from workspace
command: docker load -i /tmp/docker-image.tar
command: docker load -i /tmp/docker-image-local.tar
- run:
<<: *defaults_license_scanner
- run:
name: Run the license-scanner
command: cd /tmp/license-scanner && mode=docker dockerImages=$DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$CIRCLE_TAG make run
command: cd /tmp/license-scanner && mode=docker dockerImages=$DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:local make run
- store_artifacts:
path: /tmp/license-scanner/results
prefix: licenses
Expand Down Expand Up @@ -403,7 +400,7 @@ jobs:
at: /tmp
- run:
name: Load the pre-built docker image from workspace
command: docker load -i /tmp/docker-image.tar
command: docker load -i /tmp/docker-image-local.tar
- run:
name: Download the mojaloop/ci-config repo
command: |
Expand All @@ -419,7 +416,7 @@ jobs:
- anchore/analyze_local_image:
# Force the older version, version 0.7.0 was just published, and is broken
anchore_version: v0.6.1
image_name: "docker.io/node:16.15.0-alpine $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$CIRCLE_TAG"
image_name: "docker.io/node:16.15.0-alpine $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:local"
policy_failure: false
timeout: '500'
# Note: if the generated policy is invalid, this will fallback to the default policy, which we don't want!
Expand Down Expand Up @@ -534,26 +531,30 @@ jobs:
echo "export SLACK_RELEASE_TAG=v${CIRCLE_TAG:1}" >> $BASH_ENV
echo "export SLACK_BUILD_ID=${CIRCLE_BUILD_NUM}" >> $BASH_ENV
echo "export SLACK_CI_URL=${CIRCLE_BUILD_URL}" >> $BASH_ENV
- attach_workspace:
at: /tmp
- run:
name: Load the pre-built docker image from workspace
command: |
docker load -i /tmp/docker-image.tar
name: Setup buildx and qemu
command: |
sudo apt-get update
sudo apt-get install -y qemu-user-static
sudo apt-get install -y binfmt-support
- run:
name: Check versions
command: |
qemu-aarch64-static --version
update-binfmts --version
- run:
name: Login to Docker Hub
command: docker login -u $DOCKER_USER -p $DOCKER_PASS
- run:
name: Re-tag pre built image
command: |
docker tag $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$CIRCLE_TAG $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$RELEASE_TAG
- run:
name: Publish Docker image $CIRCLE_TAG & Latest tag to Docker Hub
name: Build Multi Arch Docker image and push
command: |
echo "Publishing $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$CIRCLE_TAG"
docker push $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$CIRCLE_TAG
echo "Publishing $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$RELEASE_TAG"
docker push $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$RELEASE_TAG
export DOCKER_CLI_EXPERIMENTAL=enabled
docker buildx create --name multi-arch-builder
docker buildx use multi-arch-builder
docker buildx inspect --bootstrap
docker buildx build --platform linux/amd64,linux/arm64 --push -t $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$RELEASE_TAG -t $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$CIRCLE_TAG .
echo "Published $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$CIRCLE_TAG"
echo "Published $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$RELEASE_TAG"
- run:
name: Set Image Digest
command: |
Expand Down Expand Up @@ -592,26 +593,30 @@ jobs:
echo "export SLACK_RELEASE_TAG=v${CIRCLE_TAG:1}" >> $BASH_ENV
echo "export SLACK_BUILD_ID=${CIRCLE_BUILD_NUM}" >> $BASH_ENV
echo "export SLACK_CI_URL=${CIRCLE_BUILD_URL}" >> $BASH_ENV
- attach_workspace:
at: /tmp
- run:
name: Load the pre-built docker image from workspace
command: |
docker load -i /tmp/docker-image.tar
name: Setup buildx and qemu
command: |
sudo apt-get update
sudo apt-get install -y qemu-user-static
sudo apt-get install -y binfmt-support
- run:
name: Check versions
command: |
qemu-aarch64-static --version
update-binfmts --version
- run:
name: Login to Docker Hub
command: docker login -u $DOCKER_USER -p $DOCKER_PASS
- run:
name: Re-tag pre built image
name: Build Multi Arch Docker image and push
command: |
docker tag $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$CIRCLE_TAG $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$RELEASE_TAG
- run:
name: Publish Docker image $CIRCLE_TAG & Latest tag to Docker Hub
command: |
echo "Publishing $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$CIRCLE_TAG"
docker push $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$CIRCLE_TAG
echo "Publishing $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$RELEASE_TAG"
docker push $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$RELEASE_TAG
export DOCKER_CLI_EXPERIMENTAL=enabled
docker buildx create --name multi-arch-builder
docker buildx use multi-arch-builder
docker buildx inspect --bootstrap
docker buildx build --platform linux/amd64,linux/arm64 --push -t $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$RELEASE_TAG -t $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$CIRCLE_TAG .
echo "Published $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$CIRCLE_TAG"
echo "Published $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$RELEASE_TAG"
- run:
name: Set Image Digest
command: |
Expand Down Expand Up @@ -752,30 +757,10 @@ workflows:
ignore:
- /feature*/
- /bugfix*/
- build:
context: org-global
requires:
- setup
- test-dependencies
- test-lint
- test-unit
- test-coverage
- test-functional
## Currently not implemented
# - test-integration
- vulnerability-check
- audit-licenses
- build-local
filters:
tags:
only: /v[0-9]+(\.[0-9]+)*(\-snapshot(\.[0-9]+)?)?(\-hotfix(\.[0-9]+)?)?(\-perf(\.[0-9]+)?)?/
branches:
ignore:
- /.*/
- license-scan:
context: org-global
requires:
- build
- build-local
filters:
tags:
only: /v[0-9]+(\.[0-9]+)*(\-snapshot(\.[0-9]+)?)?(\-hotfix(\.[0-9]+)?)?(\-perf(\.[0-9]+)?)?/
Expand All @@ -785,7 +770,7 @@ workflows:
- image-scan:
context: org-global
requires:
- build
- build-local
filters:
tags:
only: /v[0-9]+(\.[0-9]+)*(\-snapshot(\.[0-9]+)?)?(\-hotfix(\.[0-9]+)?)?(\-perf(\.[0-9]+)?)?/
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ml-testing-toolkit",
"description": "Testing Toolkit for Mojaloop implementations",
"version": "16.0.0",
"version": "16.1.0-snapshot.4",
"license": "Apache-2.0",
"author": "Vijaya Kumar Guthi, ModusBox Inc. ",
"contributors": [
Expand Down