Skip to content

ci: enable cpu builds #13

ci: enable cpu builds

ci: enable cpu builds #13

Workflow file for this run

name: Build and push docker image to registry
on:
workflow_dispatch:
push:
branches:
- 'main'
tags:
- 'v*'
pull_request:
paths:
- ".github/workflows/build.yaml"
- ".github/workflows/matrix.json"
- "integration-tests/**"
- "backends/**"
- "core/**"
- "router/**"
- "Cargo.lock"
- "rust-toolchain.toml"
- "Dockerfile"
branches:
- 'main'
jobs:
matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- id: set-matrix
run: |
branchName=$(echo '${{ github.ref }}' | sed 's,refs/heads/,,g')
matrix=$(jq --arg branchName "$branchName" 'map(. | select((.runOn==$branchName) or (.runOn=="always")) )' .github/workflows/matrix.json)
echo "{\"include\":$(echo $matrix)}"
echo ::set-output name=matrix::{\"include\":$(echo $matrix)}\"
build-and-push-image:
needs: matrix
strategy:
matrix: ${{fromJson(needs.matrix.outputs.matrix)}}
concurrency:
group: ${{ github.workflow }}-${{ github.job }}-${{matrix.name}}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
security-events: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Initialize Docker Buildx
uses: docker/setup-buildx-action@v3
with:
install: true
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v4
- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/jcudit/text-embeddings-inference
flavor: |
latest=false
tags: |
type=semver,pattern=${{ matrix.imageNamePrefix }}{{version}}
type=semver,pattern=${{ matrix.imageNamePrefix }}{{major}}.{{minor}}
type=raw,value=${{ matrix.imageNamePrefix }}latest
type=raw,value=${{ matrix.imageNamePrefix }}sha-${{ env.GITHUB_SHA_SHORT }}
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v6
with:
context: .
file: ${{ matrix.dockerfile }}
push: ${{ github.event_name != 'pull_request' }}
platforms: 'linux/amd64'
build-args: |
SCCACHE_GHA_ENABLED=${{ matrix.sccache }}
ACTIONS_CACHE_URL=${{ env.ACTIONS_CACHE_URL }}
ACTIONS_RUNTIME_TOKEN=${{ env.ACTIONS_RUNTIME_TOKEN }}
CUDA_COMPUTE_CAP=${{ matrix.cudaComputeCap }}
GIT_SHA=${{ env.GITHUB_SHA }}
DOCKER_LABEL=sha-${{ env.GITHUB_SHA_SHORT }}
${{matrix.extraBuildArgs}}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Extract metadata (tags, labels) for Docker
id: meta-grpc
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/jcudit/text-embeddings-inference
flavor: |
latest=false
tags: |
type=semver,pattern=${{ matrix.imageNamePrefix }}{{version}}-grpc
type=semver,pattern=${{ matrix.imageNamePrefix }}{{major}}.{{minor}}-grpc
type=raw,value=${{ matrix.imageNamePrefix }}latest-grpc
type=raw,value=${{ matrix.imageNamePrefix }}sha-${{ env.GITHUB_SHA_SHORT }}-grpc
- name: Build and push Docker image
id: build-and-push-grpc
uses: docker/build-push-action@v6
with:
context: .
target: grpc
file: ${{ matrix.dockerfile }}
push: ${{ github.event_name != 'pull_request' }}
platforms: 'linux/amd64'
build-args: |
SCCACHE_GHA_ENABLED=${{ matrix.sccache }}
ACTIONS_CACHE_URL=${{ env.ACTIONS_CACHE_URL }}
ACTIONS_RUNTIME_TOKEN=${{ env.ACTIONS_RUNTIME_TOKEN }}
CUDA_COMPUTE_CAP=${{ matrix.cudaComputeCap }}
GIT_SHA=${{ env.GITHUB_SHA }}
DOCKER_LABEL=sha-${{ env.GITHUB_SHA_SHORT }}
${{matrix.extraBuildArgs}}
tags: ${{ steps.meta-grpc.outputs.tags }}
labels: ${{ steps.meta-grpc.outputs.labels }}