Skip to content

Commit 6b3e1f0

Browse files
committed
Provide prebuild Docker images
1 parent 34da493 commit 6b3e1f0

File tree

4 files changed

+78
-1
lines changed

4 files changed

+78
-1
lines changed

‎.github/workflows/docker.yml‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Publish to GitHub Container Registry
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v3
15+
16+
- name: Login to ghcr
17+
uses: docker/login-action@v3
18+
with:
19+
registry: ghcr.io
20+
username: ${{ github.actor }}
21+
password: ${{ secrets.GITHUB_TOKEN }}
22+
23+
- name: Build Docker image
24+
run: docker build -t ghcr.io/softcatala/whisper-ctranslate2:latest .
25+
26+
- name: Use Docker image
27+
run: docker run -v "$(pwd)":/srv/files/ ghcr.io/softcatala/whisper-ctranslate2:latest /srv/files/e2e-tests/gossos.mp3
28+
29+
- name: Push Docker image
30+
run: docker push ghcr.io/softcatala/whisper-ctranslate2:latest
31+
32+
# These are untagged images left behind in the Docker public registry
33+
- name: Delete old images
34+
run: |
35+
gh auth login --with-token <<< "${{ secrets.GITHUB_TOKEN }}"
36+
gh api -X GET /user/packages/container/whisper-ctranslate2/versions \
37+
| jq -r '.[] | select(.metadata.container.tags | index("latest") | not) | .id' \
38+
| xargs -I {} gh api -X DELETE /user/packages/container/whisper-ctranslate2/versions/{}
39+

‎Dockerfile‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM nvidia/cuda:12.3.2-cudnn9-runtime-ubuntu22.04
2+
3+
RUN apt-get update && apt-get install -y python3-pip
4+
5+
WORKDIR /app
6+
COPY . /app
7+
8+
RUN pip3 install --no-cache-dir -U .
9+
RUN python3 -c 'from faster_whisper import WhisperModel; WhisperModel("small"); WhisperModel("medium"); WhisperModel("large-v2")'
10+
11+
ENTRYPOINT ["whisper-ctranslate2"]

‎Makefile‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
.PHONY: run install-dependencies-e2e-tests run-e2e-tests run-tests publish-release dev
1+
.PHONY: run install-dependencies-e2e-tests run-e2e-tests run-tests publish-release dev docker-build docker-run
2+
3+
docker-build:
4+
docker build -t whisper-ctranslate2 . -f Dockerfile
5+
docker image ls | grep whisper-ctranslate2
6+
7+
docker-run:
8+
docker run --gpus "device=0" -v "$(shell pwd)":/srv/files/ -it --rm whisper-ctranslate2 /srv/files/e2e-tests/gossos.mp3 --output_dir /srv/files/
29

310
run:
411
python3 setup.py sdist bdist_wheel

‎README.md‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,26 @@ Alternatively, if you are interested in the latest development (non-stable) vers
2828

2929
pip install git+https://github.com/Softcatala/whisper-ctranslate2
3030

31+
# Using prebuild Docker image
32+
33+
You can use build docker image. First pull the image:
34+
35+
docker pull ghcr.io/softcatala/whisper-ctranslate2:latest
36+
37+
The Docker image includes the small, medium" and large-v2.
38+
39+
To run it:
40+
41+
docker run --gpus "device=0" \
42+
-v "$(pwd)":/srv/files/ \
43+
-it ghcr.io/softcatala/whisper-ctranslate2:latest \
44+
/srv/files/e2e-tests/gossos.mp3 \
45+
--output_dir /srv/files/
46+
47+
Notes:
48+
* _--gpus "device=0"_ gives access to the GPU. If you do not have a GPU, remove this.
49+
* _"$(pwd)":/srv/files/_ maps your current directory to /srv/files/ inside the container
50+
3151
# CPU and GPU support
3252

3353
GPU and CPU support are provided by [CTranslate2](https://github.com/OpenNMT/CTranslate2/).

0 commit comments

Comments
 (0)