diff --git a/.github/workflows/build-and-push-image.yml b/.github/workflows/build-and-push-image.yml index 45c5e34c..5331ed0f 100644 --- a/.github/workflows/build-and-push-image.yml +++ b/.github/workflows/build-and-push-image.yml @@ -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 @@ -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 diff --git a/scripts/build_deploy.sh b/scripts/build_deploy.sh index 91fc4914..7ba18393 100755 --- a/scripts/build_deploy.sh +++ b/scripts/build_deploy.sh @@ -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}" @@ -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