build-docker.yml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. ---
  2. name: Build Docker image
  3. on:
  4. workflow_dispatch:
  5. push:
  6. branches:
  7. - dev
  8. tags:
  9. - '*'
  10. pull_request:
  11. paths:
  12. - .github/workflows/build-docker.yml
  13. - contrib/docker/Dockerfile.apache
  14. - contrib/docker/Dockerfile.fpm
  15. permissions:
  16. contents: read
  17. jobs:
  18. build-docker-apache:
  19. runs-on: ubuntu-latest
  20. steps:
  21. - name: Checkout Code
  22. uses: actions/checkout@v3
  23. - name: Docker Lint
  24. uses: hadolint/hadolint-action@v3.0.0
  25. with:
  26. dockerfile: contrib/docker/Dockerfile.apache
  27. failure-threshold: error
  28. - name: Set up QEMU
  29. uses: docker/setup-qemu-action@v2
  30. - name: Set up Docker Buildx
  31. uses: docker/setup-buildx-action@v2
  32. - name: Login to DockerHub
  33. uses: docker/login-action@v2
  34. secrets: inherit
  35. with:
  36. username: ${{ secrets.DOCKER_HUB_USERNAME }}
  37. password: ${{ secrets.DOCKER_HUB_TOKEN }}
  38. if: github.event_name != 'pull_request'
  39. - name: Fetch tags
  40. uses: docker/metadata-action@v4
  41. secrets: inherit
  42. id: meta
  43. with:
  44. images: ${{ secrets.DOCKER_HUB_ORGANISATION }}/pixelfed
  45. flavor: |
  46. latest=auto
  47. suffix=-apache
  48. tags: |
  49. type=edge,branch=dev
  50. type=pep440,pattern={{raw}}
  51. type=pep440,pattern=v{{major}}.{{minor}}
  52. type=ref,event=pr
  53. - name: Build and push Docker image
  54. uses: docker/build-push-action@v3
  55. with:
  56. context: .
  57. file: contrib/docker/Dockerfile.apache
  58. platforms: linux/amd64,linux/arm64
  59. builder: ${{ steps.buildx.outputs.name }}
  60. push: ${{ github.event_name != 'pull_request' }}
  61. tags: ${{ steps.meta.outputs.tags }}
  62. cache-from: type=gha
  63. cache-to: type=gha,mode=max
  64. build-docker-fpm:
  65. runs-on: ubuntu-latest
  66. steps:
  67. - name: Checkout Code
  68. uses: actions/checkout@v3
  69. - name: Docker Lint
  70. uses: hadolint/hadolint-action@v3.0.0
  71. with:
  72. dockerfile: contrib/docker/Dockerfile.fpm
  73. failure-threshold: error
  74. - name: Set up QEMU
  75. uses: docker/setup-qemu-action@v2
  76. - name: Set up Docker Buildx
  77. uses: docker/setup-buildx-action@v2
  78. - name: Login to DockerHub
  79. uses: docker/login-action@v2
  80. secrets: inherit
  81. with:
  82. username: ${{ secrets.DOCKER_HUB_USERNAME }}
  83. password: ${{ secrets.DOCKER_HUB_TOKEN }}
  84. if: github.event_name != 'pull_request'
  85. - name: Fetch tags
  86. uses: docker/metadata-action@v4
  87. secrets: inherit
  88. id: meta
  89. with:
  90. images: ${{ secrets.DOCKER_HUB_ORGANISATION }}/pixelfed
  91. flavor: |
  92. suffix=-fpm
  93. tags: |
  94. type=edge,branch=dev
  95. type=pep440,pattern={{raw}}
  96. type=pep440,pattern=v{{major}}.{{minor}}
  97. type=ref,event=pr
  98. - name: Build and push Docker image
  99. uses: docker/build-push-action@v3
  100. with:
  101. context: .
  102. file: contrib/docker/Dockerfile.fpm
  103. platforms: linux/amd64,linux/arm64
  104. builder: ${{ steps.buildx.outputs.name }}
  105. push: ${{ github.event_name != 'pull_request' }}
  106. tags: ${{ steps.meta.outputs.tags }}
  107. cache-from: type=gha
  108. cache-to: type=gha,mode=max