speed up ci
This commit is contained in:
parent
26b353f034
commit
fabfc6f407
1 changed files with 105 additions and 94 deletions
189
.github/workflows/build-multiarch.yml
vendored
189
.github/workflows/build-multiarch.yml
vendored
|
|
@ -6,115 +6,126 @@ on:
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
strategy:
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- platform: linux/amd64
|
# backend
|
||||||
|
- image: backend
|
||||||
|
file: ./Dockerfile.backend
|
||||||
|
tag: phact/openrag-backend
|
||||||
|
platform: linux/amd64
|
||||||
|
arch: amd64
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
arch-suffix: amd64
|
- image: backend
|
||||||
- platform: linux/arm64
|
file: ./Dockerfile.backend
|
||||||
runs-on: self-hosted
|
tag: phact/openrag-backend
|
||||||
arch-suffix: arm64
|
platform: linux/arm64
|
||||||
|
arch: arm64
|
||||||
|
runs-on: self-hosted
|
||||||
|
|
||||||
|
# frontend
|
||||||
|
- image: frontend
|
||||||
|
file: ./Dockerfile.frontend
|
||||||
|
tag: phact/openrag-frontend
|
||||||
|
platform: linux/amd64
|
||||||
|
arch: amd64
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
- image: frontend
|
||||||
|
file: ./Dockerfile.frontend
|
||||||
|
tag: phact/openrag-frontend
|
||||||
|
platform: linux/arm64
|
||||||
|
arch: arm64
|
||||||
|
runs-on: self-hosted
|
||||||
|
|
||||||
|
# opensearch
|
||||||
|
- image: opensearch
|
||||||
|
file: ./Dockerfile
|
||||||
|
tag: phact/openrag-opensearch
|
||||||
|
platform: linux/amd64
|
||||||
|
arch: amd64
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
- image: opensearch
|
||||||
|
file: ./Dockerfile
|
||||||
|
tag: phact/openrag-opensearch
|
||||||
|
platform: linux/arm64
|
||||||
|
arch: arm64
|
||||||
|
runs-on: self-hosted
|
||||||
|
|
||||||
runs-on: ${{ matrix.runs-on }}
|
runs-on: ${{ matrix.runs-on }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Extract version from pyproject.toml
|
- name: Extract version from pyproject.toml
|
||||||
id: version
|
id: version
|
||||||
run: |
|
run: |
|
||||||
VERSION=$(grep '^version = ' pyproject.toml | cut -d '"' -f 2)
|
VERSION=$(grep '^version = ' pyproject.toml | cut -d '"' -f 2)
|
||||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||||
echo "Version: $VERSION"
|
echo "Version: $VERSION"
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
- name: Build and push backend
|
- name: Build and push ${{ matrix.image }} (${{ matrix.arch }})
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: ./Dockerfile.backend
|
file: ${{ matrix.file }}
|
||||||
platforms: ${{ matrix.platform }}
|
platforms: ${{ matrix.platform }}
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
tags: phact/openrag-backend:${{ steps.version.outputs.version }}-${{ matrix.arch-suffix }}
|
tags: ${{ matrix.tag }}:${{ steps.version.outputs.version }}-${{ matrix.arch }}
|
||||||
cache-from: type=gha
|
cache-from: type=gha,scope=${{ matrix.image }}-${{ matrix.arch }}
|
||||||
cache-to: type=gha,mode=max
|
cache-to: type=gha,mode=max,scope=${{ matrix.image }}-${{ matrix.arch }}
|
||||||
|
|
||||||
- name: Build and push frontend
|
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
file: ./Dockerfile.frontend
|
|
||||||
platforms: ${{ matrix.platform }}
|
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
|
||||||
tags: phact/openrag-frontend:${{ steps.version.outputs.version }}-${{ matrix.arch-suffix }}
|
|
||||||
cache-from: type=gha
|
|
||||||
cache-to: type=gha,mode=max
|
|
||||||
|
|
||||||
- name: Build and push OpenSearch
|
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
file: ./Dockerfile
|
|
||||||
platforms: ${{ matrix.platform }}
|
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
|
||||||
tags: phact/openrag-opensearch:${{ steps.version.outputs.version }}-${{ matrix.arch-suffix }}
|
|
||||||
cache-from: type=gha
|
|
||||||
cache-to: type=gha,mode=max
|
|
||||||
|
|
||||||
manifest:
|
manifest:
|
||||||
needs: build
|
needs: build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Extract version from pyproject.toml
|
- name: Extract version from pyproject.toml
|
||||||
id: version
|
id: version
|
||||||
run: |
|
run: |
|
||||||
VERSION=$(grep '^version = ' pyproject.toml | cut -d '"' -f 2)
|
VERSION=$(grep '^version = ' pyproject.toml | cut -d '"' -f 2)
|
||||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
- name: Create and push multi-arch manifests
|
- name: Create and push multi-arch manifests
|
||||||
run: |
|
run: |
|
||||||
VERSION=${{ steps.version.outputs.version }}
|
VERSION=${{ steps.version.outputs.version }}
|
||||||
|
|
||||||
# Backend manifest
|
docker buildx imagetools create -t phact/openrag-backend:$VERSION \
|
||||||
docker buildx imagetools create -t phact/openrag-backend:$VERSION \
|
phact/openrag-backend:$VERSION-amd64 \
|
||||||
phact/openrag-backend:$VERSION-amd64 \
|
phact/openrag-backend:$VERSION-arm64
|
||||||
phact/openrag-backend:$VERSION-arm64
|
docker buildx imagetools create -t phact/openrag-backend:latest \
|
||||||
docker buildx imagetools create -t phact/openrag-backend:latest \
|
phact/openrag-backend:$VERSION-amd64 \
|
||||||
phact/openrag-backend:$VERSION-amd64 \
|
phact/openrag-backend:$VERSION-arm64
|
||||||
phact/openrag-backend:$VERSION-arm64
|
|
||||||
|
|
||||||
# Frontend manifest
|
docker buildx imagetools create -t phact/openrag-frontend:$VERSION \
|
||||||
docker buildx imagetools create -t phact/openrag-frontend:$VERSION \
|
phact/openrag-frontend:$VERSION-amd64 \
|
||||||
phact/openrag-frontend:$VERSION-amd64 \
|
phact/openrag-frontend:$VERSION-arm64
|
||||||
phact/openrag-frontend:$VERSION-arm64
|
docker buildx imagetools create -t phact/openrag-frontend:latest \
|
||||||
docker buildx imagetools create -t phact/openrag-frontend:latest \
|
phact/openrag-frontend:$VERSION-amd64 \
|
||||||
phact/openrag-frontend:$VERSION-amd64 \
|
phact/openrag-frontend:$VERSION-arm64
|
||||||
phact/openrag-frontend:$VERSION-arm64
|
|
||||||
|
|
||||||
# OpenSearch manifest
|
docker buildx imagetools create -t phact/openrag-opensearch:$VERSION \
|
||||||
docker buildx imagetools create -t phact/openrag-opensearch:$VERSION \
|
phact/openrag-opensearch:$VERSION-amd64 \
|
||||||
phact/openrag-opensearch:$VERSION-amd64 \
|
phact/openrag-opensearch:$VERSION-arm64
|
||||||
phact/openrag-opensearch:$VERSION-arm64
|
docker buildx imagetools create -t phact/openrag-opensearch:latest \
|
||||||
docker buildx imagetools create -t phact/openrag-opensearch:latest \
|
phact/openrag-opensearch:$VERSION-amd64 \
|
||||||
phact/openrag-opensearch:$VERSION-amd64 \
|
phact/openrag-opensearch:$VERSION-arm64
|
||||||
phact/openrag-opensearch:$VERSION-arm64
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue