docker.yml 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # GitHub actions workflow which builds and publishes the docker images.
  2. name: Build docker images
  3. on:
  4. push:
  5. tags: ["v*"]
  6. branches: [ master, main, develop ]
  7. workflow_dispatch:
  8. permissions:
  9. contents: read
  10. packages: write
  11. jobs:
  12. build:
  13. runs-on: ubuntu-latest
  14. steps:
  15. - name: Set up QEMU
  16. id: qemu
  17. uses: docker/setup-qemu-action@v2
  18. with:
  19. platforms: arm64
  20. - name: Set up Docker Buildx
  21. id: buildx
  22. uses: docker/setup-buildx-action@v2
  23. - name: Inspect builder
  24. run: docker buildx inspect
  25. - name: Log in to DockerHub
  26. uses: docker/login-action@v2
  27. with:
  28. username: ${{ secrets.DOCKERHUB_USERNAME }}
  29. password: ${{ secrets.DOCKERHUB_TOKEN }}
  30. - name: Log in to GHCR
  31. uses: docker/login-action@v2
  32. with:
  33. registry: ghcr.io
  34. username: ${{ github.repository_owner }}
  35. password: ${{ secrets.GITHUB_TOKEN }}
  36. - name: Calculate docker image tag
  37. id: set-tag
  38. uses: docker/metadata-action@master
  39. with:
  40. images: |
  41. docker.io/matrixdotorg/synapse
  42. ghcr.io/matrix-org/synapse
  43. flavor: |
  44. latest=false
  45. tags: |
  46. type=raw,value=develop,enable=${{ github.ref == 'refs/heads/develop' }}
  47. type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' }}
  48. type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
  49. type=pep440,pattern={{raw}}
  50. - name: Build and push all platforms
  51. uses: docker/build-push-action@v4
  52. with:
  53. push: true
  54. labels: "gitsha1=${{ github.sha }}"
  55. tags: "${{ steps.set-tag.outputs.tags }}"
  56. file: "docker/Dockerfile"
  57. platforms: linux/amd64,linux/arm64
  58. # arm64 builds OOM without the git fetch setting. c.f.
  59. # https://github.com/rust-lang/cargo/issues/10583
  60. build-args: |
  61. CARGO_NET_GIT_FETCH_WITH_CLI=true