Be less strict with types #209
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Docker Image | |
on: | |
release: | |
types: [created] | |
push: | |
branches: | |
- main | |
paths: | |
- 'app/**' | |
- 'bin/*.sh' | |
- 'config/**' | |
- 'Dockerfile' | |
- 'Dockerfile.whisper' | |
- 'Dockerfile.fasterwhisper' | |
- 'Dockerfile.whispercpp' | |
- 'install-whisper.sh' | |
- 'pyproject.toml' | |
- 'poetry.lock' | |
- '.github/workflows/docker-publish.yml' | |
pull_request: | |
branches: | |
- main | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: crimeisdown/trunk-transcribe | |
jobs: | |
build-api: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
platform: ["linux/amd64"] | |
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@v3 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build image | |
if: github.ref != 'refs/heads/main' && github.event_name != 'release' | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
load: true | |
tags: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}" | |
platforms: ${{ matrix.platform }} | |
build-args: | | |
GIT_COMMIT=${{ github.sha }} | |
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} | |
cache-to: type=inline | |
- name: Build and push | |
if: github.ref == 'refs/heads/main' || github.event_name == 'release' | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
push: true | |
tags: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}" | |
platforms: ${{ matrix.platform }} | |
build-args: | | |
GIT_COMMIT=${{ github.sha }} | |
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }} | |
cache-to: type=inline | |
build-worker: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
# GPU variants | |
model: ["small.en", "medium.en", "large"] | |
platform: ["linux/amd64"] | |
desired_cuda: ["cu117"] | |
# desired_cuda: ["cu116", "cu117"] | |
dockerfile: ["Dockerfile.whisper"] | |
# CPU variants | |
include: | |
- model: small.en | |
platform: linux/amd64 | |
desired_cuda: cpu | |
dockerfile: Dockerfile.whisper | |
- model: small.en | |
platform: linux/amd64 | |
desired_cuda: cpu-cpp | |
dockerfile: Dockerfile.whispercpp | |
- model: medium.en | |
platform: linux/amd64 | |
desired_cuda: cpu-cpp | |
dockerfile: Dockerfile.whispercpp | |
- model: large | |
platform: linux/amd64 | |
desired_cuda: cpu-cpp | |
dockerfile: Dockerfile.whispercpp | |
- model: small.en | |
platform: linux/amd64 | |
desired_cuda: fw | |
dockerfile: Dockerfile.fasterwhisper | |
- model: medium.en | |
platform: linux/amd64 | |
desired_cuda: fw | |
dockerfile: Dockerfile.fasterwhisper | |
- model: large-v2 | |
platform: linux/amd64 | |
desired_cuda: fw | |
dockerfile: Dockerfile.fasterwhisper | |
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@v3 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
if: github.ref == 'refs/heads/main' | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and test image | |
# Only test the small.en model, and do not run builds where we expect a GPU | |
if: matrix.model == 'small.en' && matrix.desired_cuda != 'cu117' && matrix.desired_cuda != 'fw' && github.event_name != 'release' | |
run: | | |
set -x | |
cp .env.example .env | |
sed -i 's/^COMPOSE_FILE=docker-compose.yml:docker-compose.gpu.yml$/COMPOSE_FILE=docker-compose.yml:docker-compose.minio.yml/g' .env | |
sed -i 's/^WHISPER_MODEL=small.en$/WHISPER_MODEL=${{ matrix.model }}/g' .env | |
sed -i 's/^DESIRED_CUDA=cu117$/DESIRED_CUDA=${{ matrix.desired_cuda }}/g' .env | |
sed -i 's/^# WORKER_DOCKERFILE=Dockerfile.whispercpp$/WORKER_DOCKERFILE=${{ matrix.dockerfile }}/g' .env | |
sed -i 's/^# POSTGRES/POSTGRES/g' .env | |
sed -i 's/^# S3_BUCKET=my-bucket$/S3_BUCKET=trunk-transcribe/g' .env | |
sed -i -E 's/^# S3_PUBLIC_URL=https(.*)$/S3_PUBLIC_URL=http:\/\/minio:9000\/trunk-transcribe/g' .env | |
sed -i 's/^# AWS_ACCESS_KEY_ID=$/AWS_ACCESS_KEY_ID=root/g' .env | |
sed -i 's/^# AWS_SECRET_ACCESS_KEY=$/AWS_SECRET_ACCESS_KEY=password/g' .env | |
sed -i 's/^# S3_ENDPOINT=$/S3_ENDPOINT=http:\/\/minio:9000/g' .env | |
echo "VERSION=${{ github.sha }}" >> .env | |
cat .env | |
cp config/whisper.json.testing config/whisper.json | |
echo "{}" > config/notifications.json | |
docker compose --ansi never build | |
docker compose --ansi never up -d --quiet-pull | |
docker compose --ansi never logs -f & | |
make test | |
- name: Build and push | |
uses: docker/build-push-action@v4 | |
if: github.ref == 'refs/heads/main' || github.event_name == 'release' | |
with: | |
context: . | |
file: ${{ matrix.dockerfile }} | |
push: true | |
tags: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}-${{ matrix.model }}-${{ matrix.desired_cuda }}" | |
platforms: ${{ matrix.platform }} | |
build-args: | | |
WHISPER_MODEL=${{ matrix.model }} | |
DESIRED_CUDA=${{ matrix.desired_cuda }} | |
GIT_COMMIT=${{ github.sha }} | |
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}-${{ matrix.model }}-${{ matrix.desired_cuda }} | |
cache-to: type=inline |