Skip to content

Commit

Permalink
Added build and push functionality for multi-arch
Browse files Browse the repository at this point in the history
  • Loading branch information
modassarrana89 committed Dec 6, 2024
1 parent 8f25d29 commit 6be2ec3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 25 deletions.
23 changes: 8 additions & 15 deletions .github/workflows/build-and-push-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ env:
IMG_REPO: model-registry
DOCKER_USER: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKER_PWD: ${{ secrets.DOCKERHUB_TOKEN }}
PUSH_IMAGE: true
BUILD_PUSH_IMAGE: true # multi-arch image is build and pushed
BUILD_IMAGE: false
jobs:
build-image:
runs-on: ubuntu-latest
Expand All @@ -43,26 +44,18 @@ jobs:
if: env.BUILD_CONTEXT == 'tag'
run: |
echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
- name: Setup QEMU
uses: docker/setup-qemu-action@v2
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and Push Image
shell: bash
run: ./scripts/build_deploy.sh
- name: Tag Latest
if: env.BUILD_CONTEXT == 'main'
shell: bash
env:
IMG: ${{ env.IMG_ORG }}/${{ env.IMG_REPO }}
BUILD_IMAGE: false # image is already built in "Build and Push 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
run: VERSION=latest ./scripts/build_deploy.sh
- name: Tag Main
if: env.BUILD_CONTEXT == 'main'
shell: bash
env:
IMG: ${{ env.IMG_ORG }}/${{ env.IMG_REPO }}
BUILD_IMAGE: false # image is already built in "Build and Push 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
run: VERSION=main ./scripts/build_deploy.sh
17 changes: 7 additions & 10 deletions scripts/build_deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ VERSION="${VERSION:-$HASH}"
BUILD_IMAGE="${BUILD_IMAGE:-true}"

# if set to 0 skip push to registry
# otherwise push it
PUSH_IMAGE="${PUSH_IMAGE:-false}"
# otherwise build and push it
BUILD_PUSH_IMAGE="${BUILD_PUSH_IMAGE:-false}"

# skip if image already existing on registry
SKIP_IF_EXISTING="${SKIP_IF_EXISTING:-false}"
Expand Down Expand Up @@ -58,18 +58,15 @@ else
echo "Skip container image build."
fi

# push container image to registry, requires login
if [[ "${PUSH_IMAGE,,}" == "true" ]]; then
echo "Pushing container image.."
# build and push container image to registry
if [[ "${BUILD_PUSH_IMAGE,,}" == "true" ]]; then
echo "Build & Push multi-arch container image.."
make \
IMG_REGISTRY="${IMG_REGISTRY}" \
IMG_ORG="${IMG_ORG}" \
IMG_REPO="${IMG_REPO}" \
IMG_VERSION="${VERSION}" \
DOCKER_USER="${DOCKER_USER}" \
DOCKER_PWD="${DOCKER_PWD}" \
docker/login \
image/push
image/buildx
else
echo "Skip container image push."
echo "Skip container image build and push."
fi

0 comments on commit 6be2ec3

Please sign in to comment.