Created
June 28, 2021 15:48
-
-
Save behroozam/84379ecea043cc0c453a3902335aa9d5 to your computer and use it in GitHub Desktop.
build multi-arch docker images in circleci
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: 2.1 | |
commands: | |
configure-dockerhub: | |
description: Configure Docker Hub access | |
steps: | |
- run: | |
name: Configure Docker Hub | |
command: | | |
[ -z "$ACCESS_TOKEN" ] && exit 0 | |
docker login --username youraccountname --password=$ACCESS_TOKEN | |
jobs: | |
build-x86: | |
docker: | |
- image: docker:latest | |
steps: | |
- checkout | |
- setup_remote_docker | |
- configure-dockerhub | |
- run: | |
name: Build and push Docker Image for x86 | |
command: | | |
docker build -t yourname/yourproject:latest-x86 migrator | |
docker push yourname/yourproject:latest-x86 | |
build-arm64: | |
machine: | |
image: ubuntu-2004:202101-01 | |
resource_class: arm.medium | |
steps: | |
- checkout | |
- configure-dockerhub | |
- run: | |
name: Build and push Docker Image for arm64 | |
command: | | |
docker build -t yourname/yourproject:latest-arm64 migrator | |
docker push yourname/yourproject:latest-arm64 | |
push-multiarch-image: | |
docker: | |
- image: docker:latest | |
steps: | |
- checkout | |
- setup_remote_docker | |
- configure-dockerhub | |
- run: | |
name: Create and push manifest for multiarch | |
command: | | |
docker manifest create \ | |
yourname/yourproject:latest \ | |
--amend yourname/yourproject:latest-arm64 \ | |
--amend yourname/yourproject:latest-x86 | |
docker manifest push yourname/yourproject:latest | |
workflows: | |
build-publish: | |
jobs: | |
- build-x86: | |
context: dockerhubsecret # the circleci context that contain your access token to dockerhub | |
filters: | |
branches: | |
only: | |
- master | |
- build-arm64: | |
context: dockerhubsecret | |
filters: | |
branches: | |
only: | |
- master | |
- push-multiarch-image: | |
context: dockerhubsecret | |
requires: | |
- build-arm64 | |
- build-x86 | |
filters: | |
branches: | |
only: | |
- master |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment