Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: Extend GH Actions to also build for ARM #72

Merged
merged 2 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 12 additions & 29 deletions .github/workflows/web-app-docker-publish.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Models web app Docker Publisher

on:
push:
# Publish `master` as Docker `latest` image.
branches:
- master
- release-*

# Publish `v1.2.3` tags as releases.
tags:
Expand All @@ -14,7 +14,8 @@ on:
pull_request:

env:
IMAGE_NAME: models-web-app
IMG: kserve/models-web-app
ARCH: linux/ppc64le,linux/amd64,linux/arm64

jobs:
# Run tests.
Expand All @@ -27,12 +28,8 @@ jobs:

- name: Run tests
run: |
if [ -f docker-compose.test.yml ]; then
docker-compose --file docker-compose.test.yml build
docker-compose --file docker-compose.test.yml run sut
else
docker build . --file Dockerfile
fi
make docker-build

# Push image to GitHub Packages.
# See also https://docs.docker.com/docker-hub/builds/
push:
Expand All @@ -48,7 +45,7 @@ jobs:
- name: Setup QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: ppc64le
platforms: ppc64le,arm64

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
Expand All @@ -61,28 +58,14 @@ jobs:

- name: export version variable
run: |
IMAGE_ID=kserve/$IMAGE_NAME

# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')

# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')

# Strip "v" prefix from tag name
# [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
TAG=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')

# Use Docker `latest` tag convention
[ "$VERSION" == "master" ] && VERSION=latest
[ "$TAG" == "master" ] && VERSION=latest

echo VERSION=$VERSION >> $GITHUB_ENV
echo IMAGE_ID=$IMAGE_ID >> $GITHUB_ENV
echo TAG=$TAG >> $GITHUB_ENV

- name: Build and push
uses: docker/build-push-action@v3
with:
platforms: linux/amd64,linux/ppc64le
context: .
file: Dockerfile
push: true
tags: ${{ env.IMAGE_ID }}:${{ env.VERSION }}
- name: Build and push multi-arch docker image
run: |
make docker-build-push-multi-arch
22 changes: 13 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
IMG ?= kserve/models-web-app
TAG ?= $(shell git describe --tags --always --dirty)
ARCH ?= linux/amd64

# We want the git tag to be the last commit to this directory so we don't
# bump the image on unrelated changes.
GIT_TAG ?= $(shell git log -n 1 --pretty=format:"%h" ./)

docker-build:
docker build -t $(IMG):$(GIT_TAG) .
docker build -t ${IMG}:${TAG} .

docker-push:
docker push $(IMG):$(GIT_TAG)
docker push $(IMG):$(TAG)

.PHONY: docker-build-multi-arch
docker-build-multi-arch: ## Build multi-arch docker images with docker buildx
docker buildx build --platform ${ARCH} --tag ${IMG}:${TAG} .

image: docker-build docker-push

# Prettier UI format check.
prettier-check:
npm run format:check --prefix frontend
.PHONY: docker-build-push-multi-arch
docker-build-push-multi-arch: ## Build multi-arch docker images with docker buildx and push to docker registry
docker buildx build --platform ${ARCH} --tag ${IMG}:${TAG} --push .

image: docker-build docker-push