docker-build.yaml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. name: Build & Push Docker Images
  2. on:
  3. push:
  4. branches:
  5. - master
  6. release:
  7. types: [published]
  8. jobs:
  9. build-amd64:
  10. runs-on: ubuntu-latest
  11. steps:
  12. - name: Checkout code
  13. uses: actions/checkout@v3
  14. - name: Set up Docker Buildx
  15. uses: docker/setup-buildx-action@v2
  16. with:
  17. install: true
  18. - name: Log in to DockerHub
  19. uses: docker/login-action@v2
  20. with:
  21. username: ${{ secrets.DOCKER_USERNAME }}
  22. password: ${{ secrets.DOCKER_PASSWORD }}
  23. - name: Extract version from release tag
  24. if: github.event_name == 'release'
  25. id: version
  26. run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
  27. - name: Build and push AMD64 Docker image
  28. if: github.ref == 'refs/heads/master' && github.event_name == 'push'
  29. run: |
  30. DOCKERFILE=app.dockerfile
  31. IMAGE_NAME=perplexica
  32. docker buildx build --platform linux/amd64 \
  33. --cache-from=type=registry,ref=itzcrazykns1337/${IMAGE_NAME}:amd64 \
  34. --cache-to=type=inline \
  35. --provenance false \
  36. -f $DOCKERFILE \
  37. -t itzcrazykns1337/${IMAGE_NAME}:amd64 \
  38. --push .
  39. - name: Build and push AMD64 release Docker image
  40. if: github.event_name == 'release'
  41. run: |
  42. DOCKERFILE=app.dockerfile
  43. IMAGE_NAME=perplexica
  44. docker buildx build --platform linux/amd64 \
  45. --cache-from=type=registry,ref=itzcrazykns1337/${IMAGE_NAME}:${{ env.RELEASE_VERSION }}-amd64 \
  46. --cache-to=type=inline \
  47. --provenance false \
  48. -f $DOCKERFILE \
  49. -t itzcrazykns1337/${IMAGE_NAME}:${{ env.RELEASE_VERSION }}-amd64 \
  50. --push .
  51. build-arm64:
  52. runs-on: ubuntu-24.04-arm
  53. steps:
  54. - name: Checkout code
  55. uses: actions/checkout@v3
  56. - name: Set up Docker Buildx
  57. uses: docker/setup-buildx-action@v2
  58. with:
  59. install: true
  60. - name: Log in to DockerHub
  61. uses: docker/login-action@v2
  62. with:
  63. username: ${{ secrets.DOCKER_USERNAME }}
  64. password: ${{ secrets.DOCKER_PASSWORD }}
  65. - name: Extract version from release tag
  66. if: github.event_name == 'release'
  67. id: version
  68. run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
  69. - name: Build and push ARM64 Docker image
  70. if: github.ref == 'refs/heads/master' && github.event_name == 'push'
  71. run: |
  72. DOCKERFILE=app.dockerfile
  73. IMAGE_NAME=perplexica
  74. docker buildx build --platform linux/arm64 \
  75. --cache-from=type=registry,ref=itzcrazykns1337/${IMAGE_NAME}:arm64 \
  76. --cache-to=type=inline \
  77. --provenance false \
  78. -f $DOCKERFILE \
  79. -t itzcrazykns1337/${IMAGE_NAME}:arm64 \
  80. --push .
  81. - name: Build and push ARM64 release Docker image
  82. if: github.event_name == 'release'
  83. run: |
  84. DOCKERFILE=app.dockerfile
  85. IMAGE_NAME=perplexica
  86. docker buildx build --platform linux/arm64 \
  87. --cache-from=type=registry,ref=itzcrazykns1337/${IMAGE_NAME}:${{ env.RELEASE_VERSION }}-arm64 \
  88. --cache-to=type=inline \
  89. --provenance false \
  90. -f $DOCKERFILE \
  91. -t itzcrazykns1337/${IMAGE_NAME}:${{ env.RELEASE_VERSION }}-arm64 \
  92. --push .
  93. manifest:
  94. needs: [build-amd64, build-arm64]
  95. runs-on: ubuntu-latest
  96. steps:
  97. - name: Log in to DockerHub
  98. uses: docker/login-action@v2
  99. with:
  100. username: ${{ secrets.DOCKER_USERNAME }}
  101. password: ${{ secrets.DOCKER_PASSWORD }}
  102. - name: Extract version from release tag
  103. if: github.event_name == 'release'
  104. id: version
  105. run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
  106. - name: Create and push multi-arch manifest for main
  107. if: github.ref == 'refs/heads/master' && github.event_name == 'push'
  108. run: |
  109. IMAGE_NAME=perplexica
  110. docker manifest create itzcrazykns1337/${IMAGE_NAME}:main \
  111. --amend itzcrazykns1337/${IMAGE_NAME}:amd64 \
  112. --amend itzcrazykns1337/${IMAGE_NAME}:arm64
  113. docker manifest push itzcrazykns1337/${IMAGE_NAME}:main
  114. - name: Create and push multi-arch manifest for releases
  115. if: github.event_name == 'release'
  116. run: |
  117. IMAGE_NAME=perplexica
  118. docker manifest create itzcrazykns1337/${IMAGE_NAME}:${{ env.RELEASE_VERSION }} \
  119. --amend itzcrazykns1337/${IMAGE_NAME}:${{ env.RELEASE_VERSION }}-amd64 \
  120. --amend itzcrazykns1337/${IMAGE_NAME}:${{ env.RELEASE_VERSION }}-arm64
  121. docker manifest push itzcrazykns1337/${IMAGE_NAME}:${{ env.RELEASE_VERSION }}