docker-build.yaml 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. name: Create and publish Docker images with specific build args
  2. # Configures this workflow to run every time a change is pushed to the branch called `release`.
  3. on:
  4. push:
  5. branches:
  6. - main
  7. - dev
  8. tags:
  9. - v*
  10. # Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
  11. env:
  12. REGISTRY: ghcr.io
  13. IMAGE_NAME: ${{ github.repository }}
  14. # There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
  15. jobs:
  16. build-and-push-image:
  17. runs-on: ubuntu-latest
  18. # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
  19. permissions:
  20. contents: read
  21. packages: write
  22. steps:
  23. - name: Checkout repository
  24. uses: actions/checkout@v4
  25. # Required for multi architecture build
  26. - name: Set up QEMU
  27. uses: docker/setup-qemu-action@v3
  28. # Required for multi architecture build
  29. - name: Set up Docker Buildx
  30. uses: docker/setup-buildx-action@v3
  31. # Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
  32. - name: Log in to the Container registry
  33. uses: docker/login-action@v3
  34. with:
  35. registry: ${{ env.REGISTRY }}
  36. username: ${{ github.actor }}
  37. password: ${{ secrets.GITHUB_TOKEN }}
  38. - name: Extract metadata for Docker images (default latest tag)
  39. id: meta-latest
  40. uses: docker/metadata-action@v5
  41. with:
  42. images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
  43. # This configuration dynamically generates tags based on the branch, tag, commit, and custom suffix for lite version.
  44. tags: |
  45. type=ref,event=branch
  46. type=ref,event=tag
  47. type=sha,prefix=git-
  48. type=semver,pattern={{version}}
  49. type=semver,pattern={{major}}.{{minor}}
  50. latest=true
  51. - name: Build and push Docker image (latest)
  52. uses: docker/build-push-action@v5
  53. with:
  54. context: .
  55. push: true
  56. platforms: linux/amd64,linux/arm64
  57. tags: ${{ steps.meta-latest.outputs.tags }}
  58. labels: ${{ steps.meta-latest.outputs.labels }}
  59. - name: Build and push Docker image with CUDA
  60. uses: docker/build-push-action@v5
  61. with:
  62. context: .
  63. push: true
  64. platforms: linux/amd64,linux/arm64
  65. tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cuda
  66. build-args: USE_CUDA=true
  67. - name: Build and push Docker image with Ollama
  68. uses: docker/build-push-action@v5
  69. with:
  70. context: .
  71. push: true
  72. platforms: linux/amd64,linux/arm64
  73. tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:with-ollama
  74. build-args: USE_OLLAMA=true