120 lines
3.9 KiB
YAML
120 lines
3.9 KiB
YAML
name: Build Multi-Architecture Docker Images
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build:
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- platform: linux/amd64
|
|
runs-on: ubuntu-latest
|
|
arch-suffix: amd64
|
|
- platform: linux/arm64
|
|
runs-on: RunnerGroup02
|
|
arch-suffix: arm64
|
|
|
|
runs-on: ${{ matrix.runs-on }}
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Extract version from pyproject.toml
|
|
id: version
|
|
run: |
|
|
VERSION=$(grep '^version = ' pyproject.toml | cut -d '"' -f 2)
|
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
echo "Version: $VERSION"
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Docker Hub
|
|
if: github.event_name != 'pull_request'
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
- name: Build and push backend
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile.backend
|
|
platforms: ${{ matrix.platform }}
|
|
push: ${{ github.event_name != 'pull_request' }}
|
|
tags: phact/openrag-backend:${{ steps.version.outputs.version }}-${{ matrix.arch-suffix }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
- 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:
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
if: github.event_name != 'pull_request'
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Extract version from pyproject.toml
|
|
id: version
|
|
run: |
|
|
VERSION=$(grep '^version = ' pyproject.toml | cut -d '"' -f 2)
|
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
- name: Create and push multi-arch manifests
|
|
run: |
|
|
VERSION=${{ steps.version.outputs.version }}
|
|
|
|
# Backend manifest
|
|
docker buildx imagetools create -t phact/openrag-backend:$VERSION \
|
|
phact/openrag-backend:$VERSION-amd64 \
|
|
phact/openrag-backend:$VERSION-arm64
|
|
docker buildx imagetools create -t phact/openrag-backend:latest \
|
|
phact/openrag-backend:$VERSION-amd64 \
|
|
phact/openrag-backend:$VERSION-arm64
|
|
|
|
# Frontend manifest
|
|
docker buildx imagetools create -t phact/openrag-frontend:$VERSION \
|
|
phact/openrag-frontend:$VERSION-amd64 \
|
|
phact/openrag-frontend:$VERSION-arm64
|
|
docker buildx imagetools create -t phact/openrag-frontend:latest \
|
|
phact/openrag-frontend:$VERSION-amd64 \
|
|
phact/openrag-frontend:$VERSION-arm64
|
|
|
|
# OpenSearch manifest
|
|
docker buildx imagetools create -t phact/openrag-opensearch:$VERSION \
|
|
phact/openrag-opensearch:$VERSION-amd64 \
|
|
phact/openrag-opensearch:$VERSION-arm64
|
|
docker buildx imagetools create -t phact/openrag-opensearch:latest \
|
|
phact/openrag-opensearch:$VERSION-amd64 \
|
|
phact/openrag-opensearch:$VERSION-arm64
|