From cb0b026a458c04ba789a9fd5a8d8a5bd9970067a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20Schr=C3=B6der?= Date: Tue, 10 May 2022 14:56:00 +0200 Subject: [PATCH 1/2] Build a linux/amd64 and linux/arm64 image --- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index baf61c5..e6a3c33 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,7 @@ build: - docker build -t contentful-labs/coredns-nodecache . + docker buildx build --platform linux/amd64 -t contentful-labs/coredns-nodecache-amd64 . + docker buildx build --platform linux/arm64 -t contentful-labs/coredns-nodecache-arm64 . + docker tag contentful-labs/coredns-nodecache-amd64 contentful-labs/coredns-nodecache run: build docker run --cap-add=NET_ADMIN --cap-add=NET_RAW --privileged -P contentful-labs/coredns-nodecache From 865e5dfb39504157b53d0448a0e9448077ff65af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20Schr=C3=B6der?= Date: Tue, 10 May 2022 14:56:30 +0200 Subject: [PATCH 2/2] ci: publish images and multi-arch manifest --- .circleci/config.yml | 46 ++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 40868e7..d02f8d7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -23,25 +23,35 @@ jobs: - checkout - run: make build - run: - name: Archive Docker image - command: docker save -o image.tar contentful-labs/coredns-nodecache + name: Archive Docker images + command: | + docker save -o image-amd64.tar contentful-labs/coredns-nodecache-amd64 + docker save -o image-arm64.tar contentful-labs/coredns-nodecache-arm64 - persist_to_workspace: root: . paths: - - ./image.tar + - ./image-amd64.tar + - ./image-arm64.tar publish-branch: executor: docker-publisher steps: - attach_workspace: at: /tmp/workspace - run: - name: Load archived Docker image - command: docker load -i /tmp/workspace/image.tar + name: Load archived Docker images + command: | + docker load -i /tmp/workspace/image-amd64.tar + docker load -i /tmp/workspace/image-arm64.tar - run: - name: publish docker image with branch + name: publish docker images with branch command: | - docker tag contentful-labs/coredns-nodecache:latest $IMAGE_NAME:$CIRCLE_BRANCH + docker tag contentful-labs/coredns-nodecache-amd64:latest $IMAGE_NAME:$CIRCLE_BRANCH-amd64 + docker tag contentful-labs/coredns-nodecache-arm64:latest $IMAGE_NAME:$CIRCLE_BRANCH-arm64 echo "$docker_password" | docker login -u "$docker_login" --password-stdin + docker push $IMAGE_NAME:$CIRCLE_BRANCH-amd64 + docker push $IMAGE_NAME:$CIRCLE_BRANCH-arm64 + docker manifest create $IMAGE_NAME:$CIRCLE_BRANCH $IMAGE_NAME:$CIRCLE_BRANCH-amd64 $IMAGE_NAME:$CIRCLE_BRANCH-arm64 + docker manifest annotate --arch arm64 $IMAGE_NAME:$CIRCLE_BRANCH $IMAGE_NAME:$CIRCLE_BRANCH-arm64 docker push $IMAGE_NAME:$CIRCLE_BRANCH publish-tag: executor: docker-publisher @@ -52,10 +62,15 @@ jobs: name: Load archived Docker image command: docker load -i /tmp/workspace/image.tar - run: - name: publish docker image with tag + name: publish docker images with tag command: | - docker tag contentful-labs/coredns-nodecache:latest $IMAGE_NAME:$CIRCLE_TAG + docker tag contentful-labs/coredns-nodecache-amd64:latest $IMAGE_NAME:$CIRCLE_TAG-amd64 + docker tag contentful-labs/coredns-nodecache-arm64:latest $IMAGE_NAME:$CIRCLE_TAG-arm64 echo "$docker_password" | docker login -u "$docker_login" --password-stdin + docker push $IMAGE_NAME:$CIRCLE_TAG-amd64 + docker push $IMAGE_NAME:$CIRCLE_TAG-arm64 + docker manifest create $IMAGE_NAME:$CIRCLE_TAG $IMAGE_NAME:$CIRCLE_TAG-amd64 $IMAGE_NAME:$CIRCLE_TAG-arm64 + docker manifest annotate --arch arm64 $IMAGE_NAME:$CIRCLE_TAG $IMAGE_NAME:$CIRCLE_TAG-arm64 docker push $IMAGE_NAME:$CIRCLE_TAG publish-master: executor: docker-publisher @@ -64,12 +79,19 @@ jobs: at: /tmp/workspace - run: name: Load archived Docker image - command: docker load -i /tmp/workspace/image.tar + command: | + docker load -i /tmp/workspace/image-amd64.tar + docker load -i /tmp/workspace/image-arm64.tar - run: - name: publish docker image with latest tag + name: publish docker images with 'latest' tag command: | - docker tag contentful-labs/coredns-nodecache:latest $IMAGE_NAME:latest + docker tag contentful-labs/coredns-nodecache-amd64:latest $IMAGE_NAME:latest-amd64 + docker tag contentful-labs/coredns-nodecache-arm64:latest $IMAGE_NAME:latest-arm64 echo "$docker_password" | docker login -u "$docker_login" --password-stdin + docker push $IMAGE_NAME:latest-amd64 + docker push $IMAGE_NAME:latest-arm64 + docker manifest create $IMAGE_NAME:latest $IMAGE_NAME:latest-amd64 $IMAGE_NAME:latest-arm64 + docker manifest annotate --arch arm64 $IMAGE_NAME:latest $IMAGE_NAME:latest-arm64 docker push $IMAGE_NAME:latest workflows: version: 2