docker.yml 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. jobs:
  11. build:
  12. runs-on: ubuntu-latest
  13. steps:
  14. - name: Set up QEMU
  15. id: qemu
  16. uses: docker/setup-qemu-action@v2
  17. with:
  18. platforms: arm64
  19. - name: Set up Docker Buildx
  20. id: buildx
  21. uses: docker/setup-buildx-action@v2
  22. - name: Inspect builder
  23. run: docker buildx inspect
  24. - name: Log in to DockerHub
  25. uses: docker/login-action@v2
  26. with:
  27. username: ${{ secrets.DOCKERHUB_USERNAME }}
  28. password: ${{ secrets.DOCKERHUB_TOKEN }}
  29. - name: Calculate docker image tag
  30. id: set-tag
  31. uses: docker/metadata-action@master
  32. with:
  33. images: matrixdotorg/synapse
  34. flavor: |
  35. latest=false
  36. tags: |
  37. type=raw,value=develop,enable=${{ github.ref == 'refs/heads/develop' }}
  38. type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' }}
  39. type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
  40. type=pep440,pattern={{raw}}
  41. - name: Build and push all platforms
  42. uses: docker/build-push-action@v3
  43. with:
  44. push: true
  45. labels: "gitsha1=${{ github.sha }}"
  46. tags: "${{ steps.set-tag.outputs.tags }}"
  47. file: "docker/Dockerfile"
  48. platforms: linux/amd64,linux/arm64
  49. # arm64 builds OOM without the git fetch setting. c.f.
  50. # https://github.com/rust-lang/cargo/issues/10583
  51. build-args: |
  52. CARGO_NET_GIT_FETCH_WITH_CLI=true