Skip to content

Fix autoscaling logic #349

Fix autoscaling logic

Fix autoscaling logic #349

name: Build Docker Image
on:
workflow_dispatch:
release:
types: [created]
push:
branches:
- main
paths:
- 'app/**'
- 'docker/**'
- 'config/**'
- 'tests/integration/**'
- 'Dockerfile*'
- '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@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
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@v5
with:
context: .
file: docker/Dockerfile
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@v5
with:
context: .
file: docker/Dockerfile
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:
# 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
desired_cuda: cpu
variant: whisper
dockerfile: Dockerfile.whisper
- model: small.en
platform: linux/amd64
desired_cuda: cu121
variant: whisper
dockerfile: Dockerfile.whisper
- model: medium.en
platform: linux/amd64
desired_cuda: cu121
variant: whisper
dockerfile: Dockerfile.whisper
- model: large-v2
platform: linux/amd64
desired_cuda: cu121
variant: whisper
dockerfile: Dockerfile.whisper
- model: large-v3
platform: linux/amd64
desired_cuda: cu121
variant: whisper
dockerfile: Dockerfile.whisper
- model: medium.en
platform: linux/amd64
desired_cuda: cpu
variant: whisper.cpp
dockerfile: Dockerfile.whispercpp
- model: large-v2
platform: linux/amd64
desired_cuda: cpu
variant: whisper.cpp
dockerfile: Dockerfile.whispercpp
- model: large-v3
platform: linux/amd64
desired_cuda: 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 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 == 'cpu' && matrix.variant == 'whisper' && github.event_name != 'release'
run: |
set -x
cp .env.testing .env
sed -i 's/^WHISPER_MODEL=small.en$/WHISPER_MODEL=${{ matrix.model }}/g' .env
sed -i 's/^DESIRED_CUDA=cu121$/DESIRED_CUDA=${{ matrix.desired_cuda }}/g' .env
sed -i 's/^WORKER_DOCKERFILE=Dockerfile.whisper$/WORKER_DOCKERFILE=${{ matrix.dockerfile }}/g' .env
echo "VERSION=${{ github.sha }}" >> .env
cat .env
{ set +x; } 2>/dev/null
sed -i 's/^# OPENAI_API_KEY=$/OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}/g' .env
sed -i 's/^# GOOGLE_GEMINI_API_KEY=$/GOOGLE_GEMINI_API_KEY=${{ secrets.GOOGLE_GEMINI_API_KEY }}/g' .env
sed -i 's/^# GOOGLE_MAPS_API_KEY=$/GOOGLE_MAPS_API_KEY=${{ secrets.GOOGLE_MAPS_API_KEY }}/g' .env
sed -i 's/^# MAPBOX_API_KEY=$/MAPBOX_API_KEY=${{ secrets.MAPBOX_API_KEY }}/g' .env
sed -i 's/^# GEOCODIO_API_KEY=$/GEOCODIO_API_KEY=${{ secrets.GEOCODIO_API_KEY }}/g' .env
sed -i 's/^# ARCGIS_USERNAME=$/ARCGIS_USERNAME=${{ secrets.ARCGIS_USERNAME }}/g' .env
sed -i 's/^# ARCGIS_PASSWORD=$/ARCGIS_PASSWORD=${{ secrets.ARCGIS_PASSWORD }}/g' .env
set -x
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 &
sleep 30
make test
- 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 }}-${{ 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.variant }}-${{ matrix.model }}-${{ matrix.desired_cuda }}
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
desired_cuda: cu121
variant: faster-whisper
dockerfile: Dockerfile.fasterwhisper
- model: large-v3
platform: linux/amd64
desired_cuda: cu121
variant: faster-whisper
dockerfile: Dockerfile.fasterwhisper
- model: large-v2
platform: linux/amd64
desired_cuda: cu121
variant: whispers2t
dockerfile: Dockerfile.whispers2t
- model: large-v3
platform: linux/amd64
desired_cuda: cu121
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 }}-${{ 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.variant }}-${{ matrix.model }}-${{ matrix.desired_cuda }}
cache-to: type=inline