Change CUDA image used #319
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: | |
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.example .env | |
sed -i 's/^COMPOSE_FILE=docker-compose.server.yml:docker-compose.worker.yml:docker-compose.gpu.yml$/COMPOSE_FILE=docker-compose.server.yml:docker-compose.worker.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=cu121$/DESIRED_CUDA=${{ matrix.desired_cuda }}/g' .env | |
sed -i 's/^WORKER_DOCKERFILE=Dockerfile.whisper$/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 | |
sed -i 's/^# GEOCODING_BOUNDS="41.6,-87.9|42,-87.5"$/GEOCODING_BOUNDS="41,-88.5|42.5,-87.5"/g' .env | |
sed -i 's/^# GEOCODING_CITY=Chicago$/GEOCODING_CITY=Chicago/g' .env | |
sed -i 's/^# GEOCODING_STATE=IL$/GEOCODING_STATE=IL/g' .env | |
sed -i 's/^# GEOCODING_COUNTRY=US$/GEOCODING_COUNTRY=US/g' .env | |
sed -i 's/^# GEOCODING_ENABLED_SYSTEMS="system1,system2"$/GEOCODING_ENABLED_SYSTEMS="chi_cpd,chi_cfd,chi_oemc,sc21102"/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-v2 | |
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-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 |