config.yml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. version: 2.1
  2. jobs:
  3. dockerhubuploadrelease:
  4. docker:
  5. - image: docker:git
  6. steps:
  7. - checkout
  8. - docker_prepare
  9. - run: docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD
  10. # for release builds, we want to get the amd64 image out asap, so first
  11. # we do an amd64-only build, before following up with a multiarch build.
  12. - docker_build:
  13. tag: -t matrixdotorg/synapse:${CIRCLE_TAG}
  14. platforms: linux/amd64
  15. - docker_build:
  16. tag: -t matrixdotorg/synapse:${CIRCLE_TAG}
  17. platforms: linux/amd64,linux/arm/v7,linux/arm64
  18. dockerhubuploadlatest:
  19. docker:
  20. - image: docker:git
  21. steps:
  22. - checkout
  23. - docker_prepare
  24. - run: docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD
  25. # for `latest`, we don't want the arm images to disappear, so don't update the tag
  26. # until all of the platforms are built.
  27. - docker_build:
  28. tag: -t matrixdotorg/synapse:latest
  29. platforms: linux/amd64,linux/arm/v7,linux/arm64
  30. workflows:
  31. build:
  32. jobs:
  33. - dockerhubuploadrelease:
  34. filters:
  35. tags:
  36. only: /v[0-9].[0-9]+.[0-9]+.*/
  37. branches:
  38. ignore: /.*/
  39. - dockerhubuploadlatest:
  40. filters:
  41. branches:
  42. only: master
  43. commands:
  44. docker_prepare:
  45. description: Sets up a remote docker server, downloads the buildx cli plugin, and enables multiarch images
  46. parameters:
  47. buildx_version:
  48. type: string
  49. default: "v0.4.1"
  50. steps:
  51. - setup_remote_docker:
  52. # 19.03.13 was the most recent available on circleci at the time of
  53. # writing.
  54. version: 19.03.13
  55. - run: apk add --no-cache curl
  56. - run: mkdir -vp ~/.docker/cli-plugins/ ~/dockercache
  57. - 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
  58. - run: chmod a+x ~/.docker/cli-plugins/docker-buildx
  59. # install qemu links in /proc/sys/fs/binfmt_misc on the docker instance running the circleci job
  60. - run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
  61. # create a context named `builder` for the builds
  62. - run: docker context create builder
  63. # create a buildx builder using the new context, and set it as the default
  64. - run: docker buildx create builder --use
  65. docker_build:
  66. description: Builds and pushed images to dockerhub using buildx
  67. parameters:
  68. platforms:
  69. type: string
  70. default: linux/amd64
  71. tag:
  72. type: string
  73. steps:
  74. - run: docker buildx build -f docker/Dockerfile --push --platform << parameters.platforms >> --label gitsha1=${CIRCLE_SHA1} << parameters.tag >> --progress=plain .