-
Notifications
You must be signed in to change notification settings - Fork 20
345 lines (318 loc) · 11 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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
# Check this guide for more information about publishing to ghcr.io with GitHub Actions:
# https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#upgrading-a-workflow-that-accesses-ghcrio
# Build the Docker image and push it to the registry
name: docker_publish
on:
push:
branches:
- "master"
tags:
- "*"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Sets the permissions granted to the GITHUB_TOKEN for the actions in this job.
permissions:
contents: read
packages: write
jobs:
# Build the ubi-no_model without cache export
docker-ubi-no_model:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: Setup docker
id: setup
uses: ./.github/workflows/docker-reused-steps
with:
tag: ubi-no_model
- name: Build:ubi-no_model
uses: docker/build-push-action@v5
id: build
with:
context: .
file: ./ubi.Dockerfile
load: true
target: no_model
labels: ${{ steps.setup.outputs.labels }}
build-args: |
VERSION=${{ github.ref_name }}
RELEASE=${{ github.run_number }}
platforms: linux/amd64
# Cache to regietry instead of gha to avoid the capacity limit.
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/whisperx:cache
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/whisperx:cache,mode=max
- name: Test ubi-no_model docker image
run: |
docker run --group-add 0 -v ".:/app" ${{ steps.build.outputs.imageid }} -- --model base --language en --device cpu --compute_type int8 --output_format srt .github/workflows/test/en.webm;
if [ ! -f en.srt ]; then
echo "The en.srt file does not exist"
exit 1
fi
echo "cat en.srt:";
cat en.srt;
if ! grep -qi 'no' en.srt; then
echo "The en.srt file does not contain the word 'no'"
exit 1
fi
echo "Test passed."
- name: Build and push:ubi-no_model
uses: docker/build-push-action@v5
with:
context: .
file: ./ubi.Dockerfile
push: true
target: no_model
tags: ${{ steps.setup.outputs.tags }}
labels: ${{ steps.setup.outputs.labels }}
build-args: |
VERSION=${{ github.ref_name }}
RELEASE=${{ github.run_number }}
platforms: linux/amd64, linux/arm64
# Cache to regietry instead of gha to avoid the capacity limit.
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/whisperx:cache
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/whisperx:cache,mode=max
sbom: true
provenance: true
# Run the no_model build first ensure that the code at least builds
docker-no_model:
runs-on: ubuntu-latest
outputs:
digest: ${{ steps.publish.outputs.digest }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: Setup docker
id: setup
uses: ./.github/workflows/docker-reused-steps
- name: Build:no_model
uses: docker/build-push-action@v5
id: build
with:
context: .
file: ./Dockerfile
load: true
target: no_model
labels: ${{ steps.setup.outputs.labels }}
build-args: |
VERSION=${{ github.ref_name }}
RELEASE=${{ github.run_number }}
platforms: linux/amd64
# Cache to regietry instead of gha to avoid the capacity limit.
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/whisperx:cache
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/whisperx:cache,mode=max
- name: Test no_model docker image
run: |
docker run --group-add 0 -v ".:/app" ${{ steps.build.outputs.imageid }} -- --model base --language en --device cpu --compute_type int8 --output_format srt .github/workflows/test/en.webm;
if [ ! -f en.srt ]; then
echo "The en.srt file does not exist"
exit 1
fi
echo "cat en.srt:";
cat en.srt;
if ! grep -qi 'no' en.srt; then
echo "The en.srt file does not contain the word 'no'"
exit 1
fi
echo "Test passed."
- name: Build and push:no_model
uses: docker/build-push-action@v5
id: publish
with:
context: .
file: ./Dockerfile
push: true
target: no_model
tags: ${{ steps.setup.outputs.tags }}
labels: ${{ steps.setup.outputs.labels }}
build-args: |
VERSION=${{ github.ref_name }}
RELEASE=${{ github.run_number }}
platforms: linux/amd64, linux/arm64
# Cache to regietry instead of gha to avoid the capacity limit.
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/whisperx:cache
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/whisperx:cache,mode=max
sbom: true
provenance: true
# Download whisper model cache
docker-cache:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
model:
- tiny
- base
- small
- medium
- large-v2
- large-v3
needs: docker-no_model # wait for docker-no_model to finish
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: Setup docker
id: setup
uses: ./.github/workflows/docker-reused-steps
with:
tag: cache-${{ matrix.model }}
- name: Build cache:${{ matrix.model }}
uses: docker/build-push-action@v5
id: build
with:
context: .
file: ./Dockerfile
push: true
target: load_whisper
tags: ${{ steps.setup.outputs.tags }}
labels: ${{ steps.setup.outputs.labels }}
build-args: |
WHISPER_MODEL=${{ matrix.model }}
NO_MODEL_STAGE=ghcr.io/jim60105/whisperx:no_model@${{ needs.docker-no_model.outputs.digest }}
VERSION=${{ github.ref_name }}
RELEASE=${{ github.run_number }}
platforms: linux/amd64, linux/arm64
# Cache to regietry instead of gha to avoid the capacity limit.
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/whisperx:cache
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/whisperx:cache,mode=max
sbom: true
provenance: true
# Run the rest of the builds in parallel
docker:
# The type of runner that the job will run on
runs-on: ubuntu-latest
strategy:
fail-fast: false
# max-parallel: 6
matrix:
lang:
- en
- fr
- de
- es
- it
- ja
- zh
- nl
- uk
- pt
- ar
- cs
- ru
- pl
- hu
- fi
- fa
- el
- tr
- da
- he
- vi
- ko
- ur
- te
- hi
- ca
- ml
# Disable language 'no' because this transcribe model is too large to build on the GitHub Actions
# https://github.com/jim60105/docker-whisperX/actions/runs/8405597972
# - no
- nn
- sk
- sl
- hr
model:
- tiny
- base
- small
- medium
- large-v2
- large-v3
needs:
- docker-no_model # wait for docker-no_model to finish
- docker-cache # wait for docker-cache to finish
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: Setup docker
id: setup
uses: ./.github/workflows/docker-reused-steps
with:
tag: ${{ matrix.model }}-${{ matrix.lang }}
- name: Get short SHA
id: get-sha
run: |
id=$(echo ${{ github.sha }} | cut -c 1-7)
echo "id=$id" >> $GITHUB_OUTPUT
- name: Build and push:${{ matrix.model }}-${{ matrix.lang }}
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
target: final
push: true
tags: ${{ steps.setup.outputs.tags }}
labels: ${{ steps.setup.outputs.labels }}
build-args: |
WHISPER_MODEL=${{ matrix.model }}
LANG=${{ matrix.lang }}
LOAD_WHISPER_STAGE=ghcr.io/jim60105/whisperx:cache-${{ matrix.model }}-${{ steps.get-sha.outputs.id }}
NO_MODEL_STAGE=ghcr.io/jim60105/whisperx:no_model@${{ needs.docker-no_model.outputs.digest }}
VERSION=${{ github.ref_name }}
RELEASE=${{ github.run_number }}
platforms: linux/amd64, linux/arm64
# Cache to regietry instead of gha to avoid the capacity limit.
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/whisperx:cache
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/whisperx:cache,mode=max
sbom: true
provenance: true
test-large-v3-zh:
name: Test large-v3-zh docker image
runs-on: ubuntu-latest
needs: docker
steps:
# We require additional space due to the large size of our image. (~10GB)
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: false
- name: Checkout
uses: actions/checkout@v4
with:
sparse-checkout: |
.github/workflows/test/**
sparse-checkout-cone-mode: false
- name: Get short SHA
id: get-sha
run: |
id=$(echo ${{ github.sha }} | cut -c 1-7)
echo "id=$id" >> $GITHUB_OUTPUT
- name: Test large-v3-zh docker image
run: |
docker run --group-add 0 -v ".:/app" ghcr.io/jim60105/whisperx:large-v3-zh-${{ steps.get-sha.outputs.id }} -- --device cpu --compute_type int8 --output_format srt .github/workflows/test/zh.webm;
if [ ! -f zh.srt ]; then
echo "The zh.srt file does not exist"
exit 1
fi
echo "cat zh.srt:";
cat zh.srt;
if ! grep -qi -e '充满' -e '充滿' zh.srt; then
echo "The zh.srt file does not contain the word '充满' or '充滿'"
exit 1
fi
echo "Test passed."