Skip to content

Merge pull request #33 from CrimeIsDown/partitioning-setup #27

Merge pull request #33 from CrimeIsDown/partitioning-setup

Merge pull request #33 from CrimeIsDown/partitioning-setup #27

name: Build Worker Docker Image
on:
workflow_dispatch:
release:
types: [created]
push:
branches:
- main
paths:
- 'app/worker.py'
- 'app/whisper/**'
- 'docker/**'
- 'Dockerfile*'
- 'pyproject.toml'
- 'uv.lock'
- '.github/workflows/docker-publish-worker.yml'
# pull_request:
# branches:
# - main
env:
REGISTRY: ghcr.io
IMAGE_NAME: crimeisdown/trunk-transcribe
jobs:
build-worker:
runs-on: ubuntu-latest
strategy:
# Docker builds are very slow, so we want to have as many complete as possible
fail-fast: false
matrix:
include:
- model: small.en
platform: linux/amd64
cuda_version: "12.1.0"
variant: whisper
dockerfile: Dockerfile.whisper
- model: medium.en
platform: linux/amd64
cuda_version: "12.1.0"
variant: whisper
dockerfile: Dockerfile.whisper
- model: large-v2
platform: linux/amd64
cuda_version: "12.1.0"
variant: whisper
dockerfile: Dockerfile.whisper
- model: large-v3
platform: linux/amd64
cuda_version: "12.1.0"
variant: whisper
dockerfile: Dockerfile.whisper
- model: medium.en
platform: linux/amd64
cuda_version: cpu
variant: whisper.cpp
dockerfile: Dockerfile.whispercpp
- model: large-v2
platform: linux/amd64
cuda_version: cpu
variant: whisper.cpp
dockerfile: Dockerfile.whispercpp
- model: large-v3
platform: linux/amd64
cuda_version: cpu
variant: whisper.cpp
dockerfile: Dockerfile.whispercpp
steps:
# https://github.com/orgs/community/discussions/25678#discussioncomment-5242449
- name: Delete huge unnecessary tools folder
run: rm -rf /opt/hostedtoolcache
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
if: github.ref == 'refs/heads/main'
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
if: github.ref == 'refs/heads/main' || github.event_name == 'release'
with:
context: .
file: docker/${{ matrix.dockerfile }}
push: true
tags: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}-${{ matrix.variant }}-${{ matrix.model }}-cuda_${{ matrix.cuda_version }}"
platforms: ${{ matrix.platform }}
build-args: |
CUDA_VERSION=${{ matrix.cuda_version }}
WHISPER_MODEL=${{ matrix.model }}
GIT_COMMIT=${{ github.sha }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}-${{ matrix.variant }}-${{ matrix.model }}-cuda_${{ matrix.cuda_version }}
cache-to: type=inline
build-worker-self-hosted:
runs-on: self-hosted
strategy:
# Docker builds are very slow, so we want to have as many complete as possible
fail-fast: false
matrix:
include:
- model: medium.en
platform: linux/amd64
cuda_version: "12.3.2"
variant: faster-whisper
dockerfile: Dockerfile.fasterwhisper
- model: large-v2
platform: linux/amd64
cuda_version: "12.3.2"
variant: faster-whisper
dockerfile: Dockerfile.fasterwhisper
- model: large-v3
platform: linux/amd64
cuda_version: "12.3.2"
variant: faster-whisper
dockerfile: Dockerfile.fasterwhisper
- model: large-v2
platform: linux/amd64
cuda_version: "12.1.0"
variant: whispers2t
dockerfile: Dockerfile.whispers2t
- model: large-v3
platform: linux/amd64
cuda_version: "12.1.0"
variant: whispers2t
dockerfile: Dockerfile.whispers2t
steps:
# https://github.com/orgs/community/discussions/25678#discussioncomment-5242449
- name: Delete huge unnecessary tools folder
run: rm -rf /opt/hostedtoolcache
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver: docker
- name: Login to DockerHub
uses: docker/login-action@v3
if: github.ref == 'refs/heads/main'
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
if: github.ref == 'refs/heads/main' || github.event_name == 'release'
with:
context: .
file: docker/${{ matrix.dockerfile }}
push: true
tags: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}-${{ matrix.variant }}-${{ matrix.model }}-cuda_${{ matrix.cuda_version }}"
platforms: ${{ matrix.platform }}
build-args: |
CUDA_VERSION=${{ matrix.cuda_version }}
WHISPER_MODEL=${{ matrix.model }}
GIT_COMMIT=${{ github.sha }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}-${{ matrix.variant }}-${{ matrix.model }}-cuda_${{ matrix.cuda_version }}
cache-to: type=inline