-
-
Notifications
You must be signed in to change notification settings - Fork 3
243 lines (238 loc) · 8.95 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
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