build-docker-image.yml 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. name: Build Docker Images
  2. on:
  3. push:
  4. branches:
  5. - main
  6. tags:
  7. - "v*"
  8. jobs:
  9. build:
  10. runs-on: ubuntu-latest-16c64g
  11. strategy:
  12. matrix:
  13. target: [webui, server]
  14. backend: [cuda, cpu]
  15. steps:
  16. - uses: actions/checkout@v4
  17. - name: Set up Docker Buildx
  18. uses: docker/setup-buildx-action@v3
  19. - name: Get Version
  20. run: |
  21. if [[ $GITHUB_REF == refs/tags/v* ]]; then
  22. version=$(basename ${GITHUB_REF})
  23. else
  24. version=nightly
  25. fi
  26. echo "version=${version}" >> $GITHUB_ENV
  27. echo "Current version: ${version}"
  28. - name: Login to Docker Hub
  29. uses: docker/login-action@v3
  30. with:
  31. username: ${{ secrets.DOCKER_USER }}
  32. password: ${{ secrets.DOCKER_PAT }}
  33. - name: Set platform for CPU builds
  34. id: platform
  35. run: |
  36. if [ "${{ matrix.backend }}" = "cpu" ]; then
  37. echo "platforms=linux/amd64,linux/arm64" >> $GITHUB_OUTPUT
  38. else
  39. echo "platforms=linux/amd64" >> $GITHUB_OUTPUT
  40. fi
  41. - name: Build and Push ${{ matrix.target }}-${{ matrix.backend }} Image
  42. uses: docker/build-push-action@v6
  43. with:
  44. context: .
  45. file: docker/Dockerfile
  46. platforms: ${{ steps.platform.outputs.platforms }}
  47. push: true
  48. target: ${{ matrix.target }}
  49. build-args: |
  50. BACKEND=${{ matrix.backend }}
  51. UV_EXTRA=${{ matrix.backend == 'cuda' && 'cu126' || 'cpu' }}
  52. tags: |
  53. fishaudio/fish-speech:${{ matrix.target }}-${{ matrix.backend }}-${{ env.version }}
  54. fishaudio/fish-speech:${{ matrix.target }}-${{ matrix.backend }}
  55. ${{ (matrix.target == 'webui' && matrix.backend == 'cuda') && format('fishaudio/fish-speech:{0}', env.version) || '' }}
  56. ${{ (matrix.target == 'webui' && matrix.backend == 'cuda') && 'fishaudio/fish-speech:latest' || '' }}
  57. outputs: type=image,oci-mediatypes=true,compression=zstd,compression-level=3,force-compression=true
  58. cache-from: type=registry,ref=fishaudio/fish-speech:${{ matrix.target }}-${{ matrix.backend }}
  59. cache-to: type=inline
  60. update-readme:
  61. runs-on: ubuntu-latest
  62. needs: build
  63. if: github.ref == 'refs/heads/main'
  64. steps:
  65. - name: Push README to Dockerhub
  66. uses: peter-evans/dockerhub-description@v4
  67. with:
  68. username: ${{ secrets.DOCKER_USER }}
  69. password: ${{ secrets.DOCKER_PAT }}
  70. repository: fishaudio/fish-speech