ci: build Docker image variants (#456)

Signed-off-by: Sébastien Prud'homme <sebastien.prudhomme@gmail.com>
This commit is contained in:
Sébastien Prud'homme 2023-05-31 19:51:02 +02:00 committed by GitHub
parent 28ee180283
commit eee3f83d98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,34 +15,42 @@ concurrency:
jobs: jobs:
docker: docker:
strategy:
matrix:
include:
- build-type: ''
platforms: 'linux/amd64,linux/arm64'
tag-latest: 'auto'
tag-suffix: ''
- build-type: 'cublas'
cuda-major-version: 11
cuda-minor-version: 7
platforms: 'linux/amd64'
tag-latest: 'false'
tag-suffix: '-cublas-cuda11'
- build-type: 'cublas'
cuda-major-version: 12
cuda-minor-version: 1
platforms: 'linux/amd64'
tag-latest: 'false'
tag-suffix: '-cublas-cuda12'
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Prepare - name: Docker meta
id: prep id: meta
run: | uses: docker/metadata-action@v4
DOCKER_IMAGE=quay.io/go-skynet/local-ai with:
VERSION=master images: quay.io/go-skynet/local-ai
SHORTREF=${GITHUB_SHA::8} tags: |
type=ref,event=branch
# If this is git tag, use the tag name as a docker tag type=semver,pattern={{raw}}
if [[ $GITHUB_REF == refs/tags/* ]]; then type=sha
VERSION=${GITHUB_REF#refs/tags/} flavor: |
fi latest=${{ matrix.tag-latest }}
TAGS="${DOCKER_IMAGE}:${VERSION},${DOCKER_IMAGE}:${SHORTREF}" suffix=${{ matrix.tag-suffix }}
# If the VERSION looks like a version number, assume that
# this is the most recent version of the image and also
# tag it 'latest'.
if [[ $VERSION =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
TAGS="$TAGS,${DOCKER_IMAGE}:latest"
fi
# Set output parameters.
echo ::set-output name=tags::${TAGS}
echo ::set-output name=docker_image::${DOCKER_IMAGE}
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@master uses: docker/setup-qemu-action@master
@ -60,23 +68,18 @@ jobs:
registry: quay.io registry: quay.io
username: ${{ secrets.LOCALAI_REGISTRY_USERNAME }} username: ${{ secrets.LOCALAI_REGISTRY_USERNAME }}
password: ${{ secrets.LOCALAI_REGISTRY_PASSWORD }} password: ${{ secrets.LOCALAI_REGISTRY_PASSWORD }}
- name: Build
if: github.event_name != 'pull_request' - name: Build and push
uses: docker/build-push-action@v4 uses: docker/build-push-action@v4
with: with:
builder: ${{ steps.buildx.outputs.name }} builder: ${{ steps.buildx.outputs.name }}
build-args: |
BUILD_TYPE=${{ matrix.build-type }}
CUDA_MAJOR_VERSION=${{ matrix.cuda-major-version }}
CUDA_MINOR_VERSION=${{ matrix.cuda-minor-version }}
context: . context: .
file: ./Dockerfile file: ./Dockerfile
platforms: linux/amd64,linux/arm64 platforms: ${{ matrix.platforms }}
push: true push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.prep.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
- name: Build PRs labels: ${{ steps.meta.outputs.labels }}
if: github.event_name == 'pull_request'
uses: docker/build-push-action@v4
with:
builder: ${{ steps.buildx.outputs.name }}
context: .
file: ./Dockerfile
platforms: linux/amd64
push: false
tags: ${{ steps.prep.outputs.tags }}