Skip to content

ci: add docker cache #7

ci: add docker cache

ci: add docker cache #7

name: docker-build-and-push
on:
workflow_dispatch:
push:
branches:
- "master"
tags:
- 'v*'
release:
types: [published]
jobs:
docker:
runs-on: ubuntu-22.04
strategy:
matrix:
dockerfile: [Dockerfile.cuda, Dockerfile.cpu]
include:
- dockerfile: Dockerfile.cuda
tag-prefix: cuda
- repository-name: Dockerfile.cpu
tag-prefix: cpu
steps:
- uses: actions/checkout@v4
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- id: meta
uses: docker/metadata-action@v5
with:
images: |
fedirz/faster-whisper-server
# https://github.com/docker/metadata-action?tab=readme-ov-file#flavor-input
flavor: |
latest=false
prefix=${{ matrix.tag-prefix }}
tags: |
type=sha
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: ${{ matrix.dockerfile }}
push: true
# TODO:
# platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=registry,ref=fedirz/faster-whisper-server:buildcache
cache-to: type=registry,ref=fedirz/faster-whisper-server:buildcache,mode=max