Skip to content

Commit

Permalink
Add GitHub Action for building and pushing UI and BFF images
Browse files Browse the repository at this point in the history
Signed-off-by: Griffin-Sullivan <[email protected]>
  • Loading branch information
Griffin-Sullivan committed Oct 1, 2024
1 parent 0c369a0 commit 3e9902a
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/build-and-push-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ on:
- '.github/ISSUE_TEMPLATE/**'
- '.github/dependabot.yml'
- 'docs/**'
- 'clients/ui/**'
env:
IMG_ORG: kubeflow
IMG_REPO: model-registry
Expand Down
94 changes: 94 additions & 0 deletions .github/workflows/build-and-push-ui-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Build and Push UI and BFF Images
on:
pull_request:
branches:
- 'main'
tags:
- 'v*'
paths:
- 'clients/ui/**'
env:
IMG_ORG: kubeflow
IMG_UI_REPO: model-registry-ui
IMG_BFF_REPO: model-registry-bff
DOCKER_USER: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKER_PWD: ${{ secrets.DOCKERHUB_TOKEN }}
PUSH_IMAGE: true
jobs:
build-image:
runs-on: ubuntu-latest
steps:
# Assign context variable for various action contexts (tag, main, CI)
- name: Assigning tag context
if: github.head_ref == '' && startsWith(github.ref, 'refs/tags/v')
run: echo "BUILD_CONTEXT=tag" >> $GITHUB_ENV
- name: Assigning main context
if: github.head_ref == '' && github.ref == 'refs/heads/main'
run: echo "BUILD_CONTEXT=main" >> $GITHUB_ENV
# checkout branch
- uses: actions/checkout@v4
# set image version
- name: Set main-branch environment
if: env.BUILD_CONTEXT == 'main'
run: |
commit_sha=${{ github.event.after }}
tag=main-${commit_sha:0:7}
echo "VERSION=${tag}" >> $GITHUB_ENV
- name: Set tag environment
if: env.BUILD_CONTEXT == 'tag'
run: |
echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
- name: Build and Push UI Image
shell: bash
env:
IMG_REPO: ${{ env.IMG_UI_REPO }}
run: ./scripts/build_deploy.sh
- name: Build and Push BFF Image
shell: bash
env:
IMG_REPO: ${{ env.IMG_BFF_REPO }}
run: ./scripts/build_deploy.sh
- name: Tag Latest UI Image
if: env.BUILD_CONTEXT == 'main'
shell: bash
env:
IMG_REPO: ${{ env.IMG_UI_REPO }}
IMG: ${{ env.IMG_ORG }}/${{ env.IMG_UI_REPO }}
BUILD_IMAGE: false # image is already built in "Build and Push UI Image" step
run: |
docker tag ${{ env.IMG }}:$VERSION ${{ env.IMG }}:latest
# BUILD_IMAGE=false skip the build, just push the tag made above
VERSION=latest ./scripts/build_deploy.sh
- name: Tag Latest BFF Image
if: env.BUILD_CONTEXT == 'main'
shell: bash
env:
IMG_REPO: ${{ env.IMG_BFF_REPO }}
IMG: ${{ env.IMG_ORG }}/${{ env.IMG_BFF_REPO }}
BUILD_IMAGE: false # image is already built in "Build and Push BFF Image" step
run: |
docker tag ${{ env.IMG }}:$VERSION ${{ env.IMG }}:latest
# BUILD_IMAGE=false skip the build, just push the tag made above
VERSION=latest ./scripts/build_deploy.sh
- name: Tag Main UI Image
if: env.BUILD_CONTEXT == 'main'
shell: bash
env:
IMG_REPO: ${{ env.IMG_UI_REPO }}
IMG: ${{ env.IMG_ORG }}/${{ env.IMG_UI_REPO }}
BUILD_IMAGE: false # image is already built in "Build and Push UI Image" step
run: |
docker tag ${{ env.IMG }}:$VERSION ${{ env.IMG }}:main
# BUILD_IMAGE=false skip the build, just push the tag made above
VERSION=main ./scripts/build_deploy.sh
- name: Tag Main BFF Image
if: env.BUILD_CONTEXT == 'main'
shell: bash
env:
IMG_REPO: ${{ env.IMG_BFF_REPO }}
IMG: ${{ env.IMG_ORG }}/${{ env.IMG_BFF_REPO }}
BUILD_IMAGE: false # image is already built in "Build and Push BFF Image" step
run: |
docker tag ${{ env.IMG }}:$VERSION ${{ env.IMG }}:main
# BUILD_IMAGE=false skip the build, just push the tag made above
VERSION=main ./scripts/build_deploy.sh
1 change: 1 addition & 0 deletions .github/workflows/build-image-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
- ".github/dependabot.yml"
- "docs/**"
- "clients/python/docs/**"
- 'clients/ui/**'
env:
IMG_ORG: kubeflow
IMG_REPO: model-registry
Expand Down
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
PROJECT_PATH := $(patsubst %/,%,$(dir $(MKFILE_PATH)))
PROJECT_BIN := $(PROJECT_PATH)/bin
GO ?= "$(shell which go)"
BFF_PATH := $(PROJECT_PATH)/clients/ui/bff
UI_PATH := $(PROJECT_PATH)/clients/ui/frontend

# add tools bin directory
PATH := $(PROJECT_BIN):$(PATH)
Expand All @@ -28,6 +30,15 @@ else
IMG := ${IMG_ORG}/${IMG_REPO}
endif

# Change Dockerfile path depending on IMG_REPO
ifeq ($(IMG_REPO),model-registry-ui)
DOCKERFILE := $(UI_PATH)/Dockerfile
endif

ifeq ($(IMG_REPO),model-registry-bff)
DOCKERFILE := $(BFF_PATH)/Dockerfile
endif

model-registry: build

# clean the ml-metadata protos and trigger a fresh new build which downloads
Expand Down
2 changes: 1 addition & 1 deletion clients/ui/bff/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ docker compose -f docker-compose[-local].yaml up

The main difference between the two docker compose files is that `-local` one builds the model registry from source, the other one, instead, download the `latest` pushed [quay.io](https://quay.io/repository/opendatahub/model-registry?tab=tags) image.

When shutting down the docker compose, you might want to clean-up the SQLite db file generated by ML Metadata, for example `./test/config/ml-metadata/metadata.sqlite.db`
When shutting down the docker compose, you might want to clean-up the SQLite db file generated by ML Metadata, for example `./test/config/ml-metadata/metadata.sqlite.db`.

# Development

Expand Down

0 comments on commit 3e9902a

Please sign in to comment.