1
0

docker.yml 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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: Checkout repository
  26. uses: actions/checkout@v3
  27. - name: Extract version from pyproject.toml
  28. # Note: explicitly requesting bash will mean bash is invoked with `-eo pipefail`, see
  29. # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell
  30. shell: bash
  31. run: |
  32. echo "SYNAPSE_VERSION=$(grep "^version" pyproject.toml | sed -E 's/version\s*=\s*["]([^"]*)["]/\1/')" >> $GITHUB_ENV
  33. - name: Log in to DockerHub
  34. uses: docker/login-action@v2
  35. with:
  36. username: ${{ secrets.DOCKERHUB_USERNAME }}
  37. password: ${{ secrets.DOCKERHUB_TOKEN }}
  38. - name: Log in to GHCR
  39. uses: docker/login-action@v2
  40. with:
  41. registry: ghcr.io
  42. username: ${{ github.repository_owner }}
  43. password: ${{ secrets.GITHUB_TOKEN }}
  44. - name: Calculate docker image tag
  45. id: set-tag
  46. uses: docker/metadata-action@master
  47. with:
  48. images: |
  49. docker.io/matrixdotorg/synapse
  50. ghcr.io/matrix-org/synapse
  51. flavor: |
  52. latest=false
  53. tags: |
  54. type=raw,value=develop,enable=${{ github.ref == 'refs/heads/develop' }}
  55. type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' }}
  56. type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
  57. type=pep440,pattern={{raw}}
  58. - name: Build and push all platforms
  59. uses: docker/build-push-action@v4
  60. with:
  61. push: true
  62. labels: |
  63. gitsha1=${{ github.sha }}
  64. org.opencontainers.image.version=${{ env.SYNAPSE_VERSION }}
  65. tags: "${{ steps.set-tag.outputs.tags }}"
  66. file: "docker/Dockerfile"
  67. platforms: linux/amd64,linux/arm64
  68. # arm64 builds OOM without the git fetch setting. c.f.
  69. # https://github.com/rust-lang/cargo/issues/10583
  70. build-args: |
  71. CARGO_NET_GIT_FETCH_WITH_CLI=true