diff --git a/.circleci/config.yml b/.circleci/config.yml index 98c217dd1d93..6becf9894bbb 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,24 +1,30 @@ -version: 2 +version: 2.1 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 . + - setup_remote_docker: + version: 18.09.3 + - docker_prepare - 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 + - docker_build: + parameters: --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 . + - setup_remote_docker: + version: 18.09.3 + - docker_prepare - run: docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD - - run: docker push matrixdotorg/synapse:latest - - run: docker push matrixdotorg/synapse:latest-py3 + - docker_build: + parameters: --label gitsha1=${CIRCLE_SHA1} -t matrixdotorg/synapse:latest -t matrixdotorg/synapse:latest-py3 workflows: - version: 2 build: jobs: - dockerhubuploadrelease: @@ -31,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.