ghcr for vector-serve #96
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and deploy embedding server | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- ".github/workflows/build-vector-serve.yml" | |
- "vector-serve/**" | |
pull_request: | |
branches: | |
- main | |
paths: | |
- ".github/workflows/build-vector-serve.yml" | |
- "vector-serve/**" | |
permissions: | |
id-token: write | |
contents: read | |
packages: write | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
tests: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.12.7 | |
- name: Setup | |
working-directory: ./vector-serve/ | |
run: make setup | |
- name: Init Model Cache | |
working-directory: ./vector-serve/ | |
run: make download.models | |
- name: Lints | |
working-directory: ./vector-serve/ | |
run: make check | |
- name: Tests | |
working-directory: ./vector-serve/ | |
run: make test | |
build_and_push_amd64: | |
name: Build and push AMD64 images | |
runs-on: ubuntu-latest | |
outputs: | |
short_sha: ${{ steps.versions.outputs.SHORT_SHA }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set version strings | |
id: versions | |
run: echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GHCR | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push -- Commit | |
run: | | |
docker build \ | |
-f ./vector-serve/Dockerfile \ | |
-t ghcr.io/chuckhend/vector-serve:${{ steps.versions.outputs.SHORT_SHA }}-amd64 . | |
docker push ghcr.io/chuckhend/vector-serve:${{ steps.versions.outputs.SHORT_SHA }}-amd64 | |
- name: Build and push -- Release | |
if: github.ref == 'refs/heads/main' | |
run: | | |
docker build \ | |
-f ./vector-serve/Dockerfile \ | |
-t ghcr.io/chuckhend/vector-serve:latest-amd64 . | |
docker push ghcr.io/chuckhend/vector-serve:latest-amd64 | |
- name: ECR Build and push -- Commit | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: ${{ secrets.GHA_IAM_ROLE }} | |
role-session-name: images-gha-docker-build-and-push | |
aws-region: ${{ secrets.AWS_REGION }} | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v2 | |
- name: Build and push | |
uses: docker/build-push-action@v6 | |
with: | |
file: ./vector-serve/Dockerfile | |
context: ./ | |
platforms: linux/amd64 | |
push: true | |
tags: | | |
${{ secrets.ECR_REGISTRY }}/vector-serve:${{ steps.versions.outputs.SHORT_SHA }} | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache | |
provenance: false | |
build_and_push_arm64: | |
name: Build and push ARM64 images | |
runs-on: ubicloud-standard-2-arm-ubuntu-2204 | |
outputs: | |
short_sha: ${{ steps.versions.outputs.SHORT_SHA }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set version strings | |
id: versions | |
run: echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GHCR | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push -- Commit | |
run: | | |
docker build \ | |
-f ./vector-serve/Dockerfile \ | |
--platform linux/arm64 \ | |
-t ghcr.io/chuckhend/vector-serve:${{ steps.versions.outputs.SHORT_SHA }}-arm64 . | |
docker push ghcr.io/chuckhend/vector-serve:${{ steps.versions.outputs.SHORT_SHA }}-arm64 | |
- name: Build and push -- Release | |
if: github.ref == 'refs/heads/main' | |
run: | | |
docker build \ | |
-f ./vector-serve/Dockerfile \ | |
--platform linux/arm64 \ | |
-t ghcr.io/chuckhend/vector-serve:latest-arm64 . | |
docker push ghcr.io/chuckhend/vector-serve:latest-arm64 | |
create_manifest: | |
name: Create and Push Manifest | |
runs-on: ubuntu-latest | |
needs: [build_and_push_arm64, build_and_push_amd64] | |
outputs: | |
short_sha: ${{ steps.versions.outputs.SHORT_SHA }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Login to GHCR | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Set version string | |
id: versions | |
run: echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
- name: Create and push Docker manifest -- Commit | |
run: | | |
docker manifest create \ | |
ghcr.io/chuckhend/vector-serve:${{ steps.versions.outputs.SHORT_SHA }} \ | |
ghcr.io/chuckhend/vector-serve:${{ steps.versions.outputs.SHORT_SHA }}-arm64 \ | |
ghcr.io/chuckhend/vector-serve:${{ steps.versions.outputs.SHORT_SHA }}-amd64 | |
docker manifest annotate ghcr.io/chuckhend/vector-serve:${{ steps.versions.outputs.SHORT_SHA }} ghcr.io/chuckhend/vector-serve:${{ steps.versions.outputs.SHORT_SHA }}-arm64 --arch arm64 --os linux | |
docker manifest annotate ghcr.io/chuckhend/vector-serve:${{ steps.versions.outputs.SHORT_SHA }} ghcr.io/chuckhend/vector-serve:${{ steps.versions.outputs.SHORT_SHA }}-amd64 --arch amd64 --os linux | |
docker manifest push ghcr.io/chuckhend/vector-serve:${{ steps.versions.outputs.SHORT_SHA }} | |
- name: Create and push Docker manifest -- latest (main) | |
# only push latest off main | |
if: github.ref == 'refs/heads/main' | |
run: | | |
docker manifest create \ | |
ghcr.io/chuckhend/vector-serve:latest \ | |
ghcr.io/chuckhend/vector-serve:latest-arm64 \ | |
ghcr.io/chuckhend/vector-serve:latest-amd64 | |
docker manifest annotate ghcr.io/chuckhend/vector-serve:latest ghcr.io/chuckhend/vector-serve:latest-arm64 --arch arm64 --os linux | |
docker manifest annotate ghcr.io/chuckhend/vector-serve:latest ghcr.io/chuckhend/vector-serve:latest-amd64 --arch amd64 --os linux | |
docker manifest push ghcr.io/chuckhend/vector-serve:latest |