From c195eaac6c286116b35d06cf4ca099ca0de4a1bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Laubacher?= Date: Sun, 3 May 2020 15:31:32 +0200 Subject: [PATCH 1/4] Add multi-arch support (amd64, arm64v8) --- .circleci/config.yml | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 98c217dd1d93..4bcedfaccf0d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,21 +1,38 @@ version: 2 jobs: dockerhubuploadrelease: - machine: true + docker: + - image: docker:git steps: - checkout - - run: docker build -f docker/Dockerfile --label gitsha1=${CIRCLE_SHA1} -t matrixdotorg/synapse:${CIRCLE_TAG} -t matrixdotorg/synapse:${CIRCLE_TAG}-py3 . - - run: docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD - - run: docker push matrixdotorg/synapse:${CIRCLE_TAG} - - run: docker push matrixdotorg/synapse:${CIRCLE_TAG}-py3 + - setup_remote_docker: + version: 18.09.3 + - run: apk add --no-cache curl + - run: mkdir -vp ~/.docker/cli-plugins/ ~/dockercache + - run: curl --silent -L "https://github.com/docker/buildx/releases/download/v0.4.1/buildx-v0.4.1.linux-amd64" > ~/.docker/cli-plugins/docker-buildx + - run: chmod a+x ~/.docker/cli-plugins/docker-buildx + - run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + - run: docker context create old-style + - run: docker buildx create old-style --use + - run: docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD + - run: docker buildx build -f docker/Dockerfile --push --platform linux/arm64/v8,linux/amd64 --label gitsha1=${CIRCLE_SHA1} -t matrixdotorg/synapse:${CIRCLE_TAG} -t matrixdotorg/synapse:${CIRCLE_TAG}-py3 . + dockerhubuploadlatest: - machine: true + docker: + - image: docker:git steps: - checkout - - run: docker build -f docker/Dockerfile --label gitsha1=${CIRCLE_SHA1} -t matrixdotorg/synapse:latest -t matrixdotorg/synapse:latest-py3 . - - run: docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD - - run: docker push matrixdotorg/synapse:latest - - run: docker push matrixdotorg/synapse:latest-py3 + - setup_remote_docker: + version: 18.09.3 + - run: apk add --no-cache curl + - run: mkdir -vp ~/.docker/cli-plugins/ ~/dockercache + - run: curl --silent -L "https://github.com/docker/buildx/releases/download/v0.4.1/buildx-v0.4.1.linux-amd64" > ~/.docker/cli-plugins/docker-buildx + - run: chmod a+x ~/.docker/cli-plugins/docker-buildx + - run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + - run: docker context create old-style + - run: docker buildx create old-style --use + - run: docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD + - run: docker buildx build -f docker/Dockerfile --push --platform linux/arm64/v8,linux/amd64 --label gitsha1=${CIRCLE_SHA1} -t matrixdotorg/synapse:latest -t matrixdotorg/synapse:latest-py3 . workflows: version: 2 From 0a55a79724b76b33bebf4f96808078ee3851fc1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Laubacher?= Date: Sat, 9 May 2020 15:28:29 +0200 Subject: [PATCH 2/4] Clean up CI --- .circleci/config.yml | 74 ++++++++++++++++++++++++++++------------- changelog.d/7397.docker | 1 + 2 files changed, 51 insertions(+), 24 deletions(-) create mode 100644 changelog.d/7397.docker diff --git a/.circleci/config.yml b/.circleci/config.yml index 4bcedfaccf0d..6becf9894bbb 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,41 +1,30 @@ -version: 2 +version: 2.1 jobs: dockerhubuploadrelease: docker: - - image: docker:git + - image: docker:git steps: - checkout - setup_remote_docker: - version: 18.09.3 - - run: apk add --no-cache curl - - run: mkdir -vp ~/.docker/cli-plugins/ ~/dockercache - - run: curl --silent -L "https://github.com/docker/buildx/releases/download/v0.4.1/buildx-v0.4.1.linux-amd64" > ~/.docker/cli-plugins/docker-buildx - - run: chmod a+x ~/.docker/cli-plugins/docker-buildx - - run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - - run: docker context create old-style - - run: docker buildx create old-style --use - - run: docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD - - run: docker buildx build -f docker/Dockerfile --push --platform linux/arm64/v8,linux/amd64 --label gitsha1=${CIRCLE_SHA1} -t matrixdotorg/synapse:${CIRCLE_TAG} -t matrixdotorg/synapse:${CIRCLE_TAG}-py3 . + version: 18.09.3 + - docker_prepare + - run: docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD + - docker_build: + parameters: --label gitsha1=${CIRCLE_SHA1} -t matrixdotorg/synapse:${CIRCLE_TAG} -t matrixdotorg/synapse:${CIRCLE_TAG}-py3 dockerhubuploadlatest: docker: - - image: docker:git + - image: docker:git steps: - checkout - setup_remote_docker: - version: 18.09.3 - - run: apk add --no-cache curl - - run: mkdir -vp ~/.docker/cli-plugins/ ~/dockercache - - run: curl --silent -L "https://github.com/docker/buildx/releases/download/v0.4.1/buildx-v0.4.1.linux-amd64" > ~/.docker/cli-plugins/docker-buildx - - run: chmod a+x ~/.docker/cli-plugins/docker-buildx - - run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - - run: docker context create old-style - - run: docker buildx create old-style --use - - run: docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD - - run: docker buildx build -f docker/Dockerfile --push --platform linux/arm64/v8,linux/amd64 --label gitsha1=${CIRCLE_SHA1} -t matrixdotorg/synapse:latest -t matrixdotorg/synapse:latest-py3 . + version: 18.09.3 + - docker_prepare + - run: docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD + - docker_build: + parameters: --label gitsha1=${CIRCLE_SHA1} -t matrixdotorg/synapse:latest -t matrixdotorg/synapse:latest-py3 workflows: - version: 2 build: jobs: - dockerhubuploadrelease: @@ -48,3 +37,40 @@ workflows: filters: branches: only: master + +commands: + docker_prepare: + description: Downloads the buildx cli plugin and enables multiarch execution + parameters: + buildx_version: + type: string + default: "v0.4.1" + steps: + - run: apk add --no-cache curl + - run: mkdir -vp ~/.docker/cli-plugins/ ~/dockercache + - run: curl --silent -L "https://github.com/docker/buildx/releases/download/<< parameters.buildx_version >>/buildx-<< parameters.buildx_version >>.linux-amd64" > ~/.docker/cli-plugins/docker-buildx + - run: chmod a+x ~/.docker/cli-plugins/docker-buildx + - run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + - run: docker context create old-style + - run: docker buildx create old-style --use + + docker_build: + description: Builds and pushed images to dockerhub using buildx + parameters: + dockerfile: + type: string + default: docker/Dockerfile + push: + type: boolean + default: true + platforms: + type: string + default: linux/arm64/v8,linux/amd64 + context: + type: string + default: . + parameters: + type: string + default: --label gitsha1=${CIRCLE_SHA1} + steps: + - run: docker buildx build -f << parameters.dockerfile >><<# parameters.push >> --push<> --platform << parameters.platforms >> << parameters.parameters >> << parameters.context >> diff --git a/changelog.d/7397.docker b/changelog.d/7397.docker new file mode 100644 index 000000000000..1db7f9de0387 --- /dev/null +++ b/changelog.d/7397.docker @@ -0,0 +1 @@ +Build multi-arch docker images. Contributed by @Starbix. From 1433c1788a25e35e470b41c8a9f0349ea6ab6d44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Laubacher?= Date: Sun, 3 May 2020 15:31:32 +0200 Subject: [PATCH 3/4] Add multi-arch support (amd64, arm64v8) --- .circleci/config.yml | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 98c217dd1d93..4bcedfaccf0d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,21 +1,38 @@ version: 2 jobs: dockerhubuploadrelease: - machine: true + docker: + - image: docker:git steps: - checkout - - run: docker build -f docker/Dockerfile --label gitsha1=${CIRCLE_SHA1} -t matrixdotorg/synapse:${CIRCLE_TAG} -t matrixdotorg/synapse:${CIRCLE_TAG}-py3 . - - run: docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD - - run: docker push matrixdotorg/synapse:${CIRCLE_TAG} - - run: docker push matrixdotorg/synapse:${CIRCLE_TAG}-py3 + - setup_remote_docker: + version: 18.09.3 + - run: apk add --no-cache curl + - run: mkdir -vp ~/.docker/cli-plugins/ ~/dockercache + - run: curl --silent -L "https://github.com/docker/buildx/releases/download/v0.4.1/buildx-v0.4.1.linux-amd64" > ~/.docker/cli-plugins/docker-buildx + - run: chmod a+x ~/.docker/cli-plugins/docker-buildx + - run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + - run: docker context create old-style + - run: docker buildx create old-style --use + - run: docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD + - run: docker buildx build -f docker/Dockerfile --push --platform linux/arm64/v8,linux/amd64 --label gitsha1=${CIRCLE_SHA1} -t matrixdotorg/synapse:${CIRCLE_TAG} -t matrixdotorg/synapse:${CIRCLE_TAG}-py3 . + dockerhubuploadlatest: - machine: true + docker: + - image: docker:git steps: - checkout - - run: docker build -f docker/Dockerfile --label gitsha1=${CIRCLE_SHA1} -t matrixdotorg/synapse:latest -t matrixdotorg/synapse:latest-py3 . - - run: docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD - - run: docker push matrixdotorg/synapse:latest - - run: docker push matrixdotorg/synapse:latest-py3 + - setup_remote_docker: + version: 18.09.3 + - run: apk add --no-cache curl + - run: mkdir -vp ~/.docker/cli-plugins/ ~/dockercache + - run: curl --silent -L "https://github.com/docker/buildx/releases/download/v0.4.1/buildx-v0.4.1.linux-amd64" > ~/.docker/cli-plugins/docker-buildx + - run: chmod a+x ~/.docker/cli-plugins/docker-buildx + - run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + - run: docker context create old-style + - run: docker buildx create old-style --use + - run: docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD + - run: docker buildx build -f docker/Dockerfile --push --platform linux/arm64/v8,linux/amd64 --label gitsha1=${CIRCLE_SHA1} -t matrixdotorg/synapse:latest -t matrixdotorg/synapse:latest-py3 . workflows: version: 2 From c5047c80d0a923c6b81512c7e24a93f2b48405ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Laubacher?= Date: Sat, 9 May 2020 15:28:29 +0200 Subject: [PATCH 4/4] Clean up CI --- .circleci/config.yml | 74 ++++++++++++++++++++++++++++------------- changelog.d/7397.docker | 1 + 2 files changed, 51 insertions(+), 24 deletions(-) create mode 100644 changelog.d/7397.docker diff --git a/.circleci/config.yml b/.circleci/config.yml index 4bcedfaccf0d..6becf9894bbb 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,41 +1,30 @@ -version: 2 +version: 2.1 jobs: dockerhubuploadrelease: docker: - - image: docker:git + - image: docker:git steps: - checkout - setup_remote_docker: - version: 18.09.3 - - run: apk add --no-cache curl - - run: mkdir -vp ~/.docker/cli-plugins/ ~/dockercache - - run: curl --silent -L "https://github.com/docker/buildx/releases/download/v0.4.1/buildx-v0.4.1.linux-amd64" > ~/.docker/cli-plugins/docker-buildx - - run: chmod a+x ~/.docker/cli-plugins/docker-buildx - - run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - - run: docker context create old-style - - run: docker buildx create old-style --use - - run: docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD - - run: docker buildx build -f docker/Dockerfile --push --platform linux/arm64/v8,linux/amd64 --label gitsha1=${CIRCLE_SHA1} -t matrixdotorg/synapse:${CIRCLE_TAG} -t matrixdotorg/synapse:${CIRCLE_TAG}-py3 . + version: 18.09.3 + - docker_prepare + - run: docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD + - docker_build: + parameters: --label gitsha1=${CIRCLE_SHA1} -t matrixdotorg/synapse:${CIRCLE_TAG} -t matrixdotorg/synapse:${CIRCLE_TAG}-py3 dockerhubuploadlatest: docker: - - image: docker:git + - image: docker:git steps: - checkout - setup_remote_docker: - version: 18.09.3 - - run: apk add --no-cache curl - - run: mkdir -vp ~/.docker/cli-plugins/ ~/dockercache - - run: curl --silent -L "https://github.com/docker/buildx/releases/download/v0.4.1/buildx-v0.4.1.linux-amd64" > ~/.docker/cli-plugins/docker-buildx - - run: chmod a+x ~/.docker/cli-plugins/docker-buildx - - run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - - run: docker context create old-style - - run: docker buildx create old-style --use - - run: docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD - - run: docker buildx build -f docker/Dockerfile --push --platform linux/arm64/v8,linux/amd64 --label gitsha1=${CIRCLE_SHA1} -t matrixdotorg/synapse:latest -t matrixdotorg/synapse:latest-py3 . + version: 18.09.3 + - docker_prepare + - run: docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD + - docker_build: + parameters: --label gitsha1=${CIRCLE_SHA1} -t matrixdotorg/synapse:latest -t matrixdotorg/synapse:latest-py3 workflows: - version: 2 build: jobs: - dockerhubuploadrelease: @@ -48,3 +37,40 @@ workflows: filters: branches: only: master + +commands: + docker_prepare: + description: Downloads the buildx cli plugin and enables multiarch execution + parameters: + buildx_version: + type: string + default: "v0.4.1" + steps: + - run: apk add --no-cache curl + - run: mkdir -vp ~/.docker/cli-plugins/ ~/dockercache + - run: curl --silent -L "https://github.com/docker/buildx/releases/download/<< parameters.buildx_version >>/buildx-<< parameters.buildx_version >>.linux-amd64" > ~/.docker/cli-plugins/docker-buildx + - run: chmod a+x ~/.docker/cli-plugins/docker-buildx + - run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + - run: docker context create old-style + - run: docker buildx create old-style --use + + docker_build: + description: Builds and pushed images to dockerhub using buildx + parameters: + dockerfile: + type: string + default: docker/Dockerfile + push: + type: boolean + default: true + platforms: + type: string + default: linux/arm64/v8,linux/amd64 + context: + type: string + default: . + parameters: + type: string + default: --label gitsha1=${CIRCLE_SHA1} + steps: + - run: docker buildx build -f << parameters.dockerfile >><<# parameters.push >> --push<> --platform << parameters.platforms >> << parameters.parameters >> << parameters.context >> diff --git a/changelog.d/7397.docker b/changelog.d/7397.docker new file mode 100644 index 000000000000..1db7f9de0387 --- /dev/null +++ b/changelog.d/7397.docker @@ -0,0 +1 @@ +Build multi-arch docker images. Contributed by @Starbix.