Skip to content

Commit

Permalink
Updating Circle CI config to move to Buildx setup
Browse files Browse the repository at this point in the history
  • Loading branch information
ShahanaFarooqui committed Jun 24, 2024
1 parent 125a3b6 commit ddb35f1
Showing 1 changed file with 66 additions and 41 deletions.
107 changes: 66 additions & 41 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit ddb35f1

Please sign in to comment.