1
0

docker.yml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. # This workflow uses actions that are not certified by GitHub.
  2. # They are provided by a third-party and are governed by
  3. # separate terms of service, privacy policy, and support
  4. # documentation.
  5. # GitHub recommends pinning actions to a commit SHA.
  6. # To get a newer version, you will need to update the SHA.
  7. # You can also reference a tag or branch, but the action may change without warning.
  8. name: Publish Docker image
  9. on:
  10. pull_request:
  11. push:
  12. branches:
  13. - master
  14. jobs:
  15. push_to_registry:
  16. name: Push Docker image to Docker Hub
  17. if: github.event.pull_request.draft == false
  18. runs-on: ubuntu-latest
  19. env:
  20. COMMIT_SHA: ${{ github.sha }}
  21. strategy:
  22. matrix:
  23. config:
  24. - { tag: "light", dockerfile: ".devops/main.Dockerfile", platforms: "linux/amd64,linux/arm64" }
  25. - { tag: "full", dockerfile: ".devops/full.Dockerfile", platforms: "linux/amd64,linux/arm64" }
  26. - { tag: "server", dockerfile: ".devops/server.Dockerfile", platforms: "linux/amd64,linux/arm64" }
  27. # NOTE(canardletter): The CUDA builds on arm64 are very slow, so I
  28. # have disabled them for now until the reason why
  29. # is understood.
  30. - { tag: "light-cuda", dockerfile: ".devops/main-cuda.Dockerfile", platforms: "linux/amd64" }
  31. - { tag: "full-cuda", dockerfile: ".devops/full-cuda.Dockerfile", platforms: "linux/amd64" }
  32. - { tag: "server-cuda", dockerfile: ".devops/server-cuda.Dockerfile", platforms: "linux/amd64" }
  33. - { tag: "light-rocm", dockerfile: ".devops/main-rocm.Dockerfile", platforms: "linux/amd64,linux/arm64" }
  34. - { tag: "full-rocm", dockerfile: ".devops/full-rocm.Dockerfile", platforms: "linux/amd64,linux/arm64" }
  35. - { tag: "server-rocm", dockerfile: ".devops/server-rocm.Dockerfile", platforms: "linux/amd64,linux/arm64" }
  36. - { tag: "light-intel", dockerfile: ".devops/main-intel.Dockerfile", platforms: "linux/amd64" }
  37. - { tag: "server-intel", dockerfile: ".devops/server-intel.Dockerfile", platforms: "linux/amd64" }
  38. steps:
  39. - name: Check out the repo
  40. uses: actions/checkout@v3
  41. - name: Set up QEMU
  42. uses: docker/setup-qemu-action@v2
  43. - name: Set up Docker Buildx
  44. uses: docker/setup-buildx-action@v2
  45. - name: Log in to Docker Hub
  46. uses: docker/login-action@v2
  47. with:
  48. registry: ghcr.io
  49. username: ${{ github.repository_owner }}
  50. password: ${{ secrets.GITHUB_TOKEN }}
  51. # https://github.com/jlumbroso/free-disk-space/tree/54081f138730dfa15788a46383842cd2f914a1be#example
  52. - name: Free Disk Space (Ubuntu)
  53. uses: jlumbroso/free-disk-space@main
  54. with:
  55. # this might remove tools that are actually needed,
  56. # if set to "true" but frees about 6 GB
  57. tool-cache: false
  58. # all of these default to true, but feel free to set to
  59. # "false" if necessary for your workflow
  60. android: true
  61. dotnet: true
  62. haskell: true
  63. large-packages: true
  64. docker-images: true
  65. swap-storage: true
  66. - name: Determine tag name
  67. id: tag
  68. shell: bash
  69. run: |
  70. BUILD_NUMBER="$(git rev-list --count HEAD)"
  71. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  72. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  73. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  74. else
  75. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  76. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  77. fi
  78. - name: Build and push Docker image (versioned)
  79. if: github.event_name == 'push'
  80. uses: docker/build-push-action@v4
  81. with:
  82. context: .
  83. push: true
  84. platforms: ${{ matrix.config.platforms }}
  85. tags: "ghcr.io/${{ github.repository_owner }}/llama.cpp:${{ matrix.config.tag }}-${{ env.COMMIT_SHA }}"
  86. file: ${{ matrix.config.dockerfile }}
  87. - name: Build and push Docker image (tagged)
  88. uses: docker/build-push-action@v4
  89. with:
  90. context: .
  91. push: ${{ github.event_name == 'push' }}
  92. platforms: ${{ matrix.config.platforms }}
  93. tags: "ghcr.io/${{ github.repository_owner }}/llama.cpp:${{ matrix.config.tag }},ghcr.io/${{ github.repository_owner }}/llama.cpp:${{ matrix.config.tag }}-${{ steps.tag.outputs.name }}"
  94. file: ${{ matrix.config.dockerfile }}