-
-
Notifications
You must be signed in to change notification settings - Fork 3
170 lines (167 loc) · 6.26 KB
/
docker-publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
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