forked from opea-project/GenAIExamples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add docker build job in manifest e2e workflow (opea-project#274)
Signed-off-by: Yingchun Guo <[email protected]>
- Loading branch information
1 parent
68e552c
commit c6b5edb
Showing
5 changed files
with
151 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
name: Image Build | ||
permissions: read-all | ||
on: | ||
workflow_call: | ||
inputs: | ||
image-repo: | ||
required: false | ||
type: string | ||
image-tag: | ||
required: true | ||
type: string | ||
mega-service: | ||
required: true | ||
type: string | ||
runner_lable: | ||
required: false | ||
type: string | ||
default: 'docker-build' | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-image-build | ||
|
||
jobs: | ||
mega-image-build: | ||
runs-on: ${{ inputs.runner_lable }} | ||
steps: | ||
- name: Checkout out Repo | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Building MegaService Docker Image | ||
id: build-megaservice-image | ||
env: | ||
IMAGE_REPO: ${{ inputs.image-repo }} | ||
IMAGE_TAG: ${{ inputs.image-tag }} | ||
mega-service: ${{ inputs.mega-service }} | ||
run: | | ||
.github/workflows/scripts/build_push.sh ${{ env.mega-service}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/bin/bash | ||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
set -xe | ||
|
||
IMAGE_REPO=${IMAGE_REPO:-$OPEA_IMAGE_REPO} | ||
IMAGE_TAG=${IMAGE_TAG:-latest} | ||
|
||
function getImagenameFromMega() { | ||
echo $(echo "$1" | tr '[:upper:]' '[:lower:]') | ||
} | ||
|
||
function checkExist() { | ||
IMAGE_NAME=$1 | ||
if [ $(curl -X GET http://localhost:5000/v2/opea/${IMAGE_NAME}/tags/list | grep -c ${IMAGE_TAG}) -ne 0 ]; then | ||
echo "true" | ||
else | ||
echo "false" | ||
fi | ||
} | ||
|
||
function docker_build() { | ||
# check if if IMAGE_TAG is not "latest" and the image exists in the registry | ||
if [ $IMAGE_TAG != "latest" && $(checkExist $1) == "true" ]; then | ||
echo "Image ${IMAGE_REPO}opea/$1:$IMAGE_TAG already exists in the registry" | ||
return | ||
fi | ||
# docker_build <service_name> <dockerfile> | ||
if [ -z "$2" ]; then | ||
DOCKERFILE_PATH=Dockerfile | ||
else | ||
DOCKERFILE_PATH=$2 | ||
fi | ||
echo "Building ${IMAGE_REPO}opea/$1:$IMAGE_TAG using Dockerfile $DOCKERFILE_PATH" | ||
# if https_proxy and http_proxy are set, pass them to docker build | ||
if [ -z "$https_proxy" ]; then | ||
docker build --no-cache -t ${IMAGE_REPO}opea/$1:$IMAGE_TAG -f $DOCKERFILE_PATH . | ||
else | ||
docker build --no-cache -t ${IMAGE_REPO}opea/$1:$IMAGE_TAG --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f $DOCKERFILE_PATH . | ||
fi | ||
docker push ${IMAGE_REPO}opea/$1:$IMAGE_TAG | ||
docker rmi ${IMAGE_REPO}opea/$1:$IMAGE_TAG | ||
} | ||
|
||
# $1 is like "apple orange pear" | ||
for MEGA_SVC in $1; do | ||
case $MEGA_SVC in | ||
"ChatQnA"|"CodeGen"|"CodeTrans"|"DocSum"|"SearchQnA") | ||
cd $MEGA_SVC/docker | ||
IMAGE_NAME="$(getImagenameFromMega $MEGA_SVC)" | ||
docker_build ${IMAGE_NAME} | ||
cd ui | ||
docker_build ${IMAGE_NAME}-ui docker/Dockerfile | ||
;; | ||
"AudioQnA"|"SearchQnA"|"Translation"|"VisualQnA") | ||
echo "Not supported yet" | ||
exit 1 | ||
;; | ||
*) | ||
echo "Unknown function: $MEGA_SVC" | ||
;; | ||
esac | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters