Skip to content

Commit

Permalink
Merge pull request #72 from kimwnasptd/feature-kimwnasptd-arm
Browse files Browse the repository at this point in the history
CI: Extend GH Actions to also build for ARM
  • Loading branch information
juliusvonkohout authored Jun 26, 2024
2 parents 20c816e + 1a838cb commit 3999015
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 38 deletions.
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

0 comments on commit 3999015

Please sign in to comment.