From ddb35f1b05c0c70231c487ca1b8d19c081b2fe8b Mon Sep 17 00:00:00 2001 From: ShahanaFarooqui Date: Mon, 24 Jun 2024 12:43:55 -0700 Subject: [PATCH] Updating Circle CI config to move to Buildx setup --- .circleci/config.yml | 107 ++++++++++++++++++++++++++----------------- 1 file changed, 66 insertions(+), 41 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9a89695d2..ad135c51d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,74 +1,99 @@ -version: 2 +version: 2.1 + +executors: + docker-executor: + docker: + - image: circleci/python:3.8 + jobs: - # Define in CircleCi Project Variables: $DOCKERHUB_REPO, $DOCKERHUB_USER, $DOCKERHUB_PASS - # Publish jobs require those variables publish_docker_linuxamd64: - machine: - docker_layer_caching: false + executor: docker-executor steps: - - checkout + - setup_remote_docker: + version: 20.10.7 + experimental: true + - checkout - run: + name: Set up Buildx + command: | + docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + docker buildx create --name rtlbuilder --use + docker buildx inspect --bootstrap + - run: + name: Build and push AMD64 image command: | LATEST_TAG="${CIRCLE_TAG:1}" DOCKERHUB_DESTINATION="$DOCKERHUB_REPO:$LATEST_TAG-amd64" DOCKERHUB_DOCKERFILE="dockerfiles/Dockerfile" - sudo docker login --username=$DOCKERHUB_USER --password=$DOCKERHUB_PASS - sudo docker build --pull -t "$DOCKERHUB_DESTINATION" -f "$DOCKERHUB_DOCKERFILE" . - sudo docker push "$DOCKERHUB_DESTINATION" - no_output_timeout: 25m + docker login --username=$DOCKERHUB_USER --password=$DOCKERHUB_PASS + docker buildx build --platform linux/amd64 --pull -t "$DOCKERHUB_DESTINATION" -f "$DOCKERHUB_DOCKERFILE" --push . publish_docker_linuxarm32v7: - machine: - docker_layer_caching: false + executor: docker-executor steps: - - checkout + - setup_remote_docker: + version: 20.10.7 + experimental: true + - checkout + - run: + name: Set up Buildx + command: | + docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + docker buildx create --name rtlbuilder --use + docker buildx inspect --bootstrap - run: + name: Build and push ARM32v7 image command: | - sudo docker run --rm --privileged multiarch/qemu-user-static:register --reset LATEST_TAG="${CIRCLE_TAG:1}" DOCKERHUB_DESTINATION="$DOCKERHUB_REPO:$LATEST_TAG-arm32v7" DOCKERHUB_DOCKERFILE="dockerfiles/Dockerfile.arm32v7" - sudo docker login --username=$DOCKERHUB_USER --password=$DOCKERHUB_PASS - sudo docker build --pull -t "$DOCKERHUB_DESTINATION" -f "$DOCKERHUB_DOCKERFILE" . - sudo docker push "$DOCKERHUB_DESTINATION" - no_output_timeout: 25m + docker login --username=$DOCKERHUB_USER --password=$DOCKERHUB_PASS + docker buildx build --platform linux/arm/v7 --pull -t "$DOCKERHUB_DESTINATION" -f "$DOCKERHUB_DOCKERFILE" --push . publish_docker_linuxarm64v8: - machine: - docker_layer_caching: false + executor: docker-executor steps: - - checkout + - setup_remote_docker: + version: 20.10.7 + experimental: true + - checkout + - run: + name: Set up Buildx + command: | + docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + docker buildx create --name rtlbuilder --use + docker buildx inspect --bootstrap - run: + name: Build and push ARM64v8 image command: | - sudo docker run --rm --privileged multiarch/qemu-user-static:register --reset LATEST_TAG="${CIRCLE_TAG:1}" DOCKERHUB_DESTINATION="$DOCKERHUB_REPO:$LATEST_TAG-arm64v8" DOCKERHUB_DOCKERFILE="dockerfiles/Dockerfile.arm64v8" - sudo docker login --username=$DOCKERHUB_USER --password=$DOCKERHUB_PASS - sudo docker build --pull -t "$DOCKERHUB_DESTINATION" -f "$DOCKERHUB_DOCKERFILE" . - sudo docker push "$DOCKERHUB_DESTINATION" - no_output_timeout: 25m + docker login --username=$DOCKERHUB_USER --password=$DOCKERHUB_PASS + docker buildx build --platform linux/arm64/v8 --pull -t "$DOCKERHUB_DESTINATION" -f "$DOCKERHUB_DOCKERFILE" --push . publish_docker_multiarch: - machine: - enabled: true - image: ubuntu-2004:2022.07.1 + executor: docker-executor steps: + - setup_remote_docker: + version: 20.10.7 + experimental: true + - checkout + - run: + name: Set up Buildx + command: | + docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + docker buildx create --name rtlbuilder --use + docker buildx inspect --bootstrap - run: + name: Create and push multi-architecture manifest command: | - # Turn on Experimental features LATEST_TAG="${CIRCLE_TAG:1}" - sudo mkdir ./.docker - sudo sh -c 'echo "{ \"experimental\": \"enabled\" }" >> ./.docker/config.json' - # - sudo docker login --username=$DOCKERHUB_USER --password=$DOCKERHUB_PASS - # - sudo docker manifest create --amend "$DOCKERHUB_REPO:$LATEST_TAG" "$DOCKERHUB_REPO:$LATEST_TAG-amd64" "$DOCKERHUB_REPO:$LATEST_TAG-arm32v7" "$DOCKERHUB_REPO:$LATEST_TAG-arm64v8" - sudo docker manifest annotate "$DOCKERHUB_REPO:$LATEST_TAG" "$DOCKERHUB_REPO:$LATEST_TAG-amd64" --os linux --arch amd64 - sudo docker manifest annotate "$DOCKERHUB_REPO:$LATEST_TAG" "$DOCKERHUB_REPO:$LATEST_TAG-arm32v7" --os linux --arch arm --variant v7 - sudo docker manifest annotate "$DOCKERHUB_REPO:$LATEST_TAG" "$DOCKERHUB_REPO:$LATEST_TAG-arm64v8" --os linux --arch arm64 --variant v8 - sudo docker manifest push "$DOCKERHUB_REPO:$LATEST_TAG" -p - no_output_timeout: 25m + docker login --username=$DOCKERHUB_USER --password=$DOCKERHUB_PASS + docker buildx imagetools create --tag "$DOCKERHUB_REPO:$LATEST_TAG" \ + "$DOCKERHUB_REPO:$LATEST_TAG-amd64" \ + "$DOCKERHUB_REPO:$LATEST_TAG-arm32v7" \ + "$DOCKERHUB_REPO:$LATEST_TAG-arm64v8" workflows: version: 2