diff --git a/.github/workflows/composite/docker-build/action.yml b/.github/workflows/composite/docker-build/action.yml new file mode 100644 index 000000000..a93e5b50e --- /dev/null +++ b/.github/workflows/composite/docker-build/action.yml @@ -0,0 +1,80 @@ +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +# Source: https://github.com/intel/ai-containers/blob/main/.github/action.yml + +--- +name: Build Container Example +description: Given the inputs found below, build all containers found in a docker-compose.yaml file for a given configuration +author: tyler.titsworth@intel.com +inputs: + example_dir: + description: Directory with docker-compose.yaml to build + required: true + type: string + env_overrides: + description: Bash Env Variable Overrides in `KEY=VAL && KEY2=VAL2` format + required: false + type: string + registry: + description: Container Registry URL + required: false + default: 'opea-project' + type: string +outputs: + container-example: + description: "Container Example" + value: ${{ steps.container-output.outputs.example }} +runs: + using: composite + steps: + # This step generates a random number to use as the project number + # which can help avoid collisions with parallel builds on the same system + - name: Generate Project Number + shell: bash + run: echo "project-number=$(shuf -i 0-10000 -n1)" >> $GITHUB_ENV + - name: Build Containers + shell: bash + run: | + REGISTRY=${{ inputs.registry }} \ + COMPOSE_PROJECT_NAME=${{ env.project-number }} \ + ${{ inputs.env_overrides }} docker compose -p ${{ env.project-number }} up --build --force-recreate --always-recreate-deps --no-start + working-directory: ${{ inputs.example_dir }} + - name: Print Containers + id: container-output + shell: bash + run: | + mkdir matrix + images=$(REGISTRY=${{ inputs.registry }} \ + COMPOSE_PROJECT_NAME=${{ env.project-number }} \ + ${{ inputs.env_overrides }} docker compose -p ${{ env.project-number }} images --format json) + for image in $(echo $images | jq -r --arg registry "$REGISTRY" '.[] | select(.Repository | contains($registry)) | .Tag'); do + echo "$image" > matrix/$image.txt + done + echo "example=${{ inputs.example_dir }}" | tr '/' '_' >> $GITHUB_OUTPUT + working-directory: ${{ inputs.example_dir }} + - uses: actions/upload-artifact@v4 + with: + name: ${{ env.project-number }}-${{ steps.container-output.outputs.example }} + path: ${{ inputs.example_dir }}/matrix/* + retention-days: 1 + overwrite: true + - name: Push Containers + shell: bash + run: | + REGISTRY=${{ inputs.registry }} \ + COMPOSE_PROJECT_NAME=${{ env.project-number }} \ + ${{ inputs.env_overrides }} docker compose -p ${{ env.project-number }} push + working-directory: ${{ inputs.example_dir }} + - name: Un-Tag Containers + if: ${{ always() }} + shell: bash + run: | + REGISTRY=${{ inputs.registry }} \ + COMPOSE_PROJECT_NAME=${{ env.project-number }} \ + ${{ inputs.env_overrides }} docker compose -p ${{ env.project-number }} down --rmi all + working-directory: ${{ inputs.example_dir }} + - name: Remove Containers + if: ${{ always() }} + shell: bash + run: docker system prune --force diff --git a/.github/workflows/composite/scan/action.yml b/.github/workflows/composite/scan/action.yml new file mode 100644 index 000000000..a2c26dc43 --- /dev/null +++ b/.github/workflows/composite/scan/action.yml @@ -0,0 +1,26 @@ +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +# Source: https://github.com/intel/ai-containers/blob/main/.github/scan/action.yml + +name: 'Aqua Security Trivy' +description: 'Scans container images for vulnerabilities with Trivy without building the image. For use behind firewalls.' +author: 'tyler.titsworth@intel.com' +inputs: + image-ref: + description: 'image reference(for backward compatibility)' + required: true + output: + description: 'writes results to a file with the specified file name' + required: true +runs: + using: 'docker' + image: "docker://ghcr.io/aquasecurity/trivy" + entrypoint: trivy + args: + - '--timeout=30m' + - image + - '--format=table' + - '--no-progress' + - '--output=${{ inputs.output }}' + - ${{ inputs.image-ref }} diff --git a/.github/workflows/container-build.yml b/.github/workflows/container-build.yml deleted file mode 100644 index dbbeeb5d8..000000000 --- a/.github/workflows/container-build.yml +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright (C) 2024 Intel Corporation -# SPDX-License-Identifier: Apache-2.0 - -name: Container Build -permissions: read-all -on: - workflow_dispatch: - schedule: - - cron: "35 1 * * 5" -jobs: - # https://github.com/intel/ai-containers/blob/main/.github/action.yml - build-containers: - runs-on: docker - env: - REGISTRY: ${{ secrets.REGISTRY }} - REPO: ${{ secrets.REPO }} - steps: - - uses: step-security/harden-runner@v2 - with: - egress-policy: audit - - uses: actions/checkout@v4 - - uses: docker/login-action@v3 - with: - registry: ${{ secrets.REGISTRY }} - username: ${{ secrets.REGISTRY_USER }} - password: ${{ secrets.REGISTRY_TOKEN }} - - name: Build Containers - run: | - docker compose -p ${GITHUB_RUN_NUMBER} build --no-cache - working-directory: .github/workflows/docker - - name: Print Containers to Summary - run: | - docker compose -p ${GITHUB_RUN_NUMBER} images --format json | jq -r --arg registry "$REGISTRY" '.[] | select(.Repository | contains($registry)) | .Tag' >> $GITHUB_STEP_SUMMARY - - name: Push Containers - run: | - docker compose -p ${GITHUB_RUN_NUMBER} push - working-directory: .github/workflows/docker - - name: Un-Tag Containers - run: | - docker compose -p ${GITHUB_RUN_NUMBER} down --rmi all - working-directory: .github/workflows/docker - - name: Remove Containers - if: always() - run: docker system prune --force diff --git a/.github/workflows/container-ci.yaml b/.github/workflows/container-ci.yaml new file mode 100644 index 000000000..5b0c64c6b --- /dev/null +++ b/.github/workflows/container-ci.yaml @@ -0,0 +1,197 @@ +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +name: Example Container CI +permissions: read-all +on: + workflow_call: + inputs: + example_dir: + required: true + type: string + scan: + default: true + required: false + type: boolean + test: + default: true + required: false + type: boolean + publish: + default: false + required: false + type: boolean +jobs: +#################################################################################################### +# Compose Build +#################################################################################################### + build-containers: + runs-on: ubuntu-latest # local registry label + outputs: + example: ${{ steps.build-example.outputs.container-example }} + steps: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0 + with: + registry: ${{ secrets.REGISTRY }} + username: ${{ secrets.REGISTRY_USER }} + password: ${{ secrets.REGISTRY_TOKEN }} + - name: Build Container example + id: build-example + uses: ./.github/workflows/composite/docker-build + with: + example_dir: ${{ inputs.example_dir }} + env_overrides: ${{ inputs.env_overrides || env.env_overrides || '' }} + registry: ${{ secrets.REGISTRY }} +#################################################################################################### +# Trivy Scan +#################################################################################################### + setup-scan: + needs: [build-containers] + if: ${{ fromJSON(inputs.scan) }} + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.scan-matrix.outputs.matrix }} + steps: + - name: Harden Runner + uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 + with: + egress-policy: audit + - uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 + with: + path: matrix + - name: Set Matrix + id: scan-matrix + run: echo "matrix=$(cat matrix/*-${{ needs.build-containers.outputs.example }}/*.txt | jq -R '.' | jq -sc '. | unique')" >> $GITHUB_OUTPUT + scan-containers: + needs: [setup-scan] + if: ${{ fromJSON(inputs.scan) }} + runs-on: ubuntu-latest # local registry label + strategy: + matrix: + container: ${{ fromJSON(needs.setup-scan.outputs.matrix) }} + fail-fast: false + steps: + - name: Harden Runner + uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 + with: + egress-policy: audit + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0 + with: + registry: ${{ secrets.REGISTRY }} + username: ${{ secrets.REGISTRY_USER }} + password: ${{ secrets.REGISTRY_TOKEN }} + - name: Downcase example Dir + run: echo "example_dir=${EXAMPLE_DIR,,}" >> ${GITHUB_ENV} + env: + EXAMPLE_DIR: ${{ inputs.example_dir }} + - name: Pull Image + run: docker pull ${{ secrets.REGISTRY }}/${{ env.example_dir }}:${{ matrix.container }} + - name: Scan Container + uses: ./.github/workflows/composite/scan + with: + image-ref: ${{ secrets.REGISTRY }}/${{ env.example_dir }}:${{ matrix.container }} + output: ${{ matrix.container }}-${{ env.example_dir }}-scan.txt + - name: Cleanup + if: always() + run: docker rmi -f ${{ secrets.REGISTRY }}/${{ env.example_dir }}:${{ matrix.container }} + # Requires GitHub Advanced Security + # - uses: github/codeql-action/upload-sarif@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11 + # with: + # sarif_file: '${{ matrix.container }}-${{ env.example_dir }}-scan.sarif' + # category: '${{ matrix.container }}' + # continue-on-error: true + - uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4 + with: + name: ${{ matrix.container }}-${{ env.example_dir }}-scan + path: ${{ matrix.container }}-${{ env.example_dir }}-scan.txt + overwrite: true +#################################################################################################### +# Validation +#################################################################################################### + setup-test: + needs: [build-containers] + if: ${{ fromJSON(inputs.test) }} + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.test-matrix.outputs.matrix }} + steps: + - name: Harden Runner + uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 + with: + egress-policy: audit + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + with: + fetch-depth: 0 + - name: Get Tests + id: test-matrix + run: | + echo "matrix=$(find ${{ inputs.example_dir }}/tests -type f -name 'test_*.sh' -print | \ + sed -n 's|.*/\(test_[^_]*_on_\([^\.]*\)\).sh|\{"test": "\1", "hardware_label": "\2"}|p' | \ + jq -sc .)" >> $GITHUB_OUTPUT + # ex: [{"test":"test_audioqna_on_xeon","hardware_label":"xeon"},{"test":"test_audioqna_on_gaudi","hardware_label":"gaudi"}] + test-containers: + needs: [setup-test] + if: ${{ needs.setup-test.outputs.matrix != '[]' && fromJSON(inputs.test) }} + runs-on: ${{ matrix.tests.hardware_label }} + strategy: + matrix: + tests: ${{ fromJson(needs.setup-test.outputs.matrix) }} + experimental: [true] + fail-fast: false + steps: + - uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 + with: + egress-policy: audit + - name: Set Variables + run: | + echo "lower_example=${EXAMPLE_DIR,,}" >> ${GITHUB_ENV} + echo "date=$(date +%Y%m%d%H%M%S)" >> ${GITHUB_ENV} + env: + EXAMPLE_DIR: ${{ inputs.example_dir }} + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - uses: azure/setup-kubectl@v4 + if: ${{ contains(matrix.tests.test, "gmc") || contains(matrix.tests.test, "manifest") }} + - name: Run Test + run: bash ${{ matrix.tests.test }}.sh + env: + REGISTRY: ${{ secrets.REGISTRY }} + IMAGE_REPO: $OPEA_IMAGE_REPO + IMAGE_TAG: $GITHUB_RUN_NUMBER + APP_NAMESPACE: $lower_example-$date + ROLLOUT_TIMEOUT_SECONDS: 1800s + KUBECTL_TIMEOUT_SECONDS: 60s + continue_test: true + should_cleanup: false + skip_validate: true +#################################################################################################### +# Publish +#################################################################################################### + publish: + needs: [build-containers, scan-containers, test-containers] + if: ${{ fromJSON(inputs.publish) }} + runs-on: ubuntu-latest # local registry label + steps: + - name: Harden Runner + uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 + with: + egress-policy: audit + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0 + with: + username: ${{ secrets.DOCKERHUB_USER }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Pull Images + run: docker compose pull + working-directory: ${{ inputs.example_dir }} + - name: Push Images + run: docker compose push + working-directory: ${{ inputs.example_dir }} + - name: Cleanup + if: always() + run: | + docker logout + docker compose down + echo 'y' | docker system prune + working-directory: ${{ inputs.example_dir }} diff --git a/.github/workflows/docker/docker-compose.yaml b/.github/workflows/docker/docker-compose.yaml deleted file mode 100644 index c0e9c53cf..000000000 --- a/.github/workflows/docker/docker-compose.yaml +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright (C) 2024 Intel Corporation -# SPDX-License-Identifier: Apache-2.0 - -services: - chatqna-megaservice-server: - build: - args: - http_proxy: ${http_proxy} - https_proxy: ${https_proxy} - no_proxy: ${no_proxy} - context: ../../../ChatQnA/microservice/xeon - dockerfile: docker/Dockerfile - image: ${REGISTRY}/${REPO}:chatqna-megaservice-server - pull_policy: always - chatqna-ui-server: - build: - context: ../../../ChatQnA/ui - extends: chatqna-megaservice-server - image: ${REGISTRY}/${REPO}:chatqna-ui-server - codegen-megaservice-server: - build: - context: ../../../CodeGen/microservice/xeon - extends: chatqna-megaservice-server - image: ${REGISTRY}/${REPO}:codegen-megaservice-server - codegen-ui-server: - build: - context: ../../../CodeGen/ui - extends: chatqna-megaservice-server - image: ${REGISTRY}/${REPO}:codegen-ui-server diff --git a/.github/workflows/example-manual-ci.yml b/.github/workflows/example-manual-ci.yml new file mode 100644 index 000000000..10917a1ad --- /dev/null +++ b/.github/workflows/example-manual-ci.yml @@ -0,0 +1,54 @@ +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +name: Build Specific Examples +on: + workflow_dispatch: + inputs: + examples: + default: 'example1, example2' + description: 'List of comma-separated examples to test' + required: true + type: string + scan: + default: true + description: 'Scan all examples with Trivy' + required: false + type: boolean + test: + default: true + description: 'Test Examples' + required: false + type: boolean + publish: + default: false + description: 'Publish Images to Dockerhub' + required: false + type: boolean +permissions: read-all +jobs: + setup-matrix: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.get-matrix.outputs.matrix }} + steps: + - name: Create Matrix + id: get-matrix + run: | + EXAMPLES=($(echo ${{ github.event.inputs.examples }} | tr ',' ' ')) + EXAMPLES_JSON=$(printf '%s\n' "${EXAMPLES[@]}" | jq -R '.' | jq -sc '.') + echo "matrix=$EXAMPLES_JSON" >> $GITHUB_OUTPUT + container-ci: + needs: [setup-matrix] + strategy: + matrix: + example: ${{ fromJson(needs.setup-matrix.outputs.matrix) }} + experimental: [true] + fail-fast: false + uses: opea-project/genaiexamples/.github/workflows/container-ci.yaml@main + with: + example_dir: ${{ matrix.example }} + scan: ${{ fromJSON(inputs.scan) }} + test: ${{ fromJSON(inputs.test) }} + publish: ${{ fromJSON(inputs.publish) }} + secrets: inherit diff --git a/.github/workflows/example-weekly-ci.yaml b/.github/workflows/example-weekly-ci.yaml new file mode 100644 index 000000000..65af0a6b6 --- /dev/null +++ b/.github/workflows/example-weekly-ci.yaml @@ -0,0 +1,47 @@ +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +name: Weekly Container Tests +on: + schedule: + - cron: "0 0 * * 0" + workflow_dispatch: null + push: + tags: ['**'] # whenever a tag is created/modified +permissions: read-all +jobs: + get-examples: + runs-on: ubuntu-latest + outputs: + examples: ${{ steps.example-list.outputs.FOLDERS }} + steps: + - name: Harden Runner + uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 + with: + egress-policy: audit + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - name: Output example Directories + id: example-list + run: | + DOCKER_COMPOSE_PATHS=() + for path in $(find . -name 'docker-compose.yaml'); do + DIR_PATH=$(dirname "$path") + DOCKER_COMPOSE_PATHS+=("${DIR_PATH:2}") + done + # Convert the array to a JSON array + DOCKER_COMPOSE_PATHS_JSON=$(printf '%s\n' "${DOCKER_COMPOSE_PATHS[@]}" | uniq | jq -R '.' | jq -sc '.') + echo "FOLDERS=$DOCKER_COMPOSE_PATHS_JSON" >> $GITHUB_OUTPUT + pipeline-ci: + needs: [get-examples] + strategy: + matrix: + example: ${{ fromJson(needs.get-examples.outputs.examples) }} + experimental: [true] + fail-fast: false + uses: opea-project/genaiexamples/.github/workflows/container-ci.yaml@main + with: + example_dir: ${{ matrix.example }} + scan: false + test: true + publish: false + secrets: inherit diff --git a/.github/workflows/scripts/build_push.sh b/.github/workflows/scripts/build_push.sh deleted file mode 100755 index 466463a27..000000000 --- a/.github/workflows/scripts/build_push.sh +++ /dev/null @@ -1,66 +0,0 @@ -#!/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 - 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"|"Translation"|"AudioQnA"|"SearchQnA") - cd $MEGA_SVC/docker - IMAGE_NAME="$(getImagenameFromMega $MEGA_SVC)" - docker_build ${IMAGE_NAME} - cd ui - docker_build ${IMAGE_NAME}-ui docker/Dockerfile - if [ "$MEGA_SVC" == "ChatQnA" ];then - docker_build ${IMAGE_NAME}-conversation-ui docker/Dockerfile.react - fi - ;; - "VisualQnA") - echo "Not supported yet" - ;; - *) - echo "Unknown function: $MEGA_SVC" - ;; - esac -done diff --git a/.gitignore b/.gitignore index 3a5650d21..9f81129da 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +**/data +**/GenAIComps **/node_modules **/.svelte-kit **/package-lock.json @@ -5,4 +7,4 @@ **/playwright/.cache/ **/test-results/ -__pycache__/ \ No newline at end of file +__pycache__/ diff --git a/AudioQnA/docker-compose.yaml b/AudioQnA/docker-compose.yaml new file mode 100644 index 000000000..5ec76d045 --- /dev/null +++ b/AudioQnA/docker-compose.yaml @@ -0,0 +1,20 @@ +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +# Container CI for AudioQnA +services: + audioqna: + build: + args: + http_proxy: ${http_proxy} + https_proxy: ${https_proxy} + no_proxy: "" + context: ./docker + dockerfile: Dockerfile + image: ${REGISTRY:-opea}/audioqna:${GITHUB_RUN_NUMBER:-latest} + audioqna-ui: # This image isn't being utilized, but does exist. + build: + context: ./docker/ui + dockerfile: ./docker/Dockerfile + extends: audioqna + image: ${REGISTRY:-opea}/audioqna-ui:${GITHUB_RUN_NUMBER:-latest} diff --git a/AudioQnA/docker/gaudi/README.md b/AudioQnA/docker/gaudi/README.md index d896dba1c..6d3b53e92 100644 --- a/AudioQnA/docker/gaudi/README.md +++ b/AudioQnA/docker/gaudi/README.md @@ -34,14 +34,14 @@ docker build -t opea/speecht5-gaudi:latest --build-arg https_proxy=$https_proxy docker build -t opea/tts:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/tts/Dockerfile . ``` -### 6. Build MegaService Docker Image +### 6. Build MegaService Docker Images To construct the Mega Service, we utilize the [GenAIComps](https://github.com/opea-project/GenAIComps.git) microservice pipeline within the `audioqna.py` Python script. Build the MegaService Docker image using the command below: ```bash git clone https://github.com/opea-project/GenAIExamples.git -cd GenAIExamples/AudioQnA/docker -docker build --no-cache -t opea/audioqna:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f Dockerfile . +cd GenAIExamples/AudioQnA +docker compose build ``` Then run the command `docker images`, you will have following images ready: diff --git a/AudioQnA/docker/gaudi/docker_compose.yaml b/AudioQnA/docker/gaudi/docker-compose.yaml similarity index 97% rename from AudioQnA/docker/gaudi/docker_compose.yaml rename to AudioQnA/docker/gaudi/docker-compose.yaml index 5d8b34a6b..68b668dd6 100644 --- a/AudioQnA/docker/gaudi/docker_compose.yaml +++ b/AudioQnA/docker/gaudi/docker-compose.yaml @@ -90,7 +90,7 @@ services: HUGGINGFACEHUB_API_TOKEN: ${HUGGINGFACEHUB_API_TOKEN} restart: unless-stopped audioqna-gaudi-backend-server: - image: opea/audioqna:latest + image: ${REGISTRY:-opea}/audioqna:${GITHUB_RUN_NUMBER:-latest} container_name: audioqna-gaudi-backend-server depends_on: - asr diff --git a/AudioQnA/docker/xeon/README.md b/AudioQnA/docker/xeon/README.md index 1e88182a9..1ea6073c8 100644 --- a/AudioQnA/docker/xeon/README.md +++ b/AudioQnA/docker/xeon/README.md @@ -34,14 +34,14 @@ docker build -t opea/speecht5:latest --build-arg https_proxy=$https_proxy --buil docker build -t opea/tts:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/tts/Dockerfile . ``` -### 6. Build MegaService Docker Image +### 6. Build MegaService Docker Images -To construct the Mega Service, we utilize the [GenAIComps](https://github.com/opea-project/GenAIComps.git) microservice pipeline within the `audioqna.py` Python script. Build the MegaService Docker image using the command below: +To construct the Mega Service, we utilize the [GenAIComps](https://github.com/opea-project/GenAIComps.git) microservice pipeline within the `audioqna.py` Python script. Build the MegaService Docker images using the command below: ```bash git clone https://github.com/opea-project/GenAIExamples.git -cd GenAIExamples/AudioQnA/docker -docker build --no-cache -t opea/audioqna:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f Dockerfile . +cd GenAIExamples/AudioQnA +docker compose build ``` Then run the command `docker images`, you will have following images ready: @@ -52,6 +52,7 @@ Then run the command `docker images`, you will have following images ready: 4. `opea/speecht5:latest` 5. `opea/tts:latest` 6. `opea/audioqna:latest` +7. `opea/qudioqna-ui:latest` ## 🚀 Set the environment variables diff --git a/AudioQnA/docker/xeon/docker_compose.yaml b/AudioQnA/docker/xeon/docker-compose.yaml similarity index 97% rename from AudioQnA/docker/xeon/docker_compose.yaml rename to AudioQnA/docker/xeon/docker-compose.yaml index b8966c719..846e46f4a 100644 --- a/AudioQnA/docker/xeon/docker_compose.yaml +++ b/AudioQnA/docker/xeon/docker-compose.yaml @@ -2,8 +2,6 @@ # Copyright (C) 2024 Intel Corporation # SPDX-License-Identifier: Apache-2.0 -version: "3.8" - services: whisper-service: image: opea/whisper:latest @@ -73,7 +71,7 @@ services: HUGGINGFACEHUB_API_TOKEN: ${HUGGINGFACEHUB_API_TOKEN} restart: unless-stopped audioqna-xeon-backend-server: - image: opea/audioqna:latest + image: ${REGISTRY:-opea}/audioqna:${GITHUB_RUN_NUMBER:-latest} container_name: audioqna-xeon-backend-server depends_on: - asr diff --git a/AudioQnA/tests/test_audioqna_on_gaudi.sh b/AudioQnA/tests/test_audioqna_on_gaudi.sh index 13991d1f2..2af46ae6b 100644 --- a/AudioQnA/tests/test_audioqna_on_gaudi.sh +++ b/AudioQnA/tests/test_audioqna_on_gaudi.sh @@ -11,22 +11,7 @@ ip_address=$(hostname -I | awk '{print $1}') function build_docker_images() { cd $WORKPATH - git clone https://github.com/opea-project/GenAIComps.git - cd GenAIComps - - docker build -t opea/whisper-gaudi:latest -f comps/asr/whisper/Dockerfile_hpu . - - docker build -t opea/asr:latest -f comps/asr/Dockerfile . - docker build -t opea/llm-tgi:latest -f comps/llms/text-generation/tgi/Dockerfile . - docker build -t opea/speecht5-gaudi:latest -f comps/tts/speecht5/Dockerfile_hpu . - docker build -t opea/tts:latest -f comps/tts/Dockerfile . - - docker pull ghcr.io/huggingface/tgi-gaudi:2.0.1 - - cd .. - - cd $WORKPATH/docker - docker build --no-cache -t opea/audioqna:latest -f Dockerfile . + docker compose build # cd $WORKPATH/docker/ui # docker build --no-cache -t opea/audioqna-ui:latest -f docker/Dockerfile . @@ -55,27 +40,24 @@ function start_services() { # sed -i "s/backend_address/$ip_address/g" $WORKPATH/docker/ui/svelte/.env - if [[ "$IMAGE_REPO" != "" ]]; then - # Replace the container name with a test-specific name - echo "using image repository $IMAGE_REPO and image tag $IMAGE_TAG" - sed -i "s#image: opea/audioqna:latest#image: opea/audioqna:${IMAGE_TAG}#g" docker_compose.yaml - sed -i "s#image: opea/audioqna-ui:latest#image: opea/audioqna-ui:${IMAGE_TAG}#g" docker_compose.yaml - sed -i "s#image: opea/*#image: ${IMAGE_REPO}opea/#g" docker_compose.yaml - echo "cat docker_compose.yaml" - cat docker_compose.yaml - fi - + # Replace the container name with a test-specific name + # echo "using image repository $IMAGE_REPO and image tag $IMAGE_TAG" + # sed -i "s#image: opea/chatqna:latest#image: opea/chatqna:${IMAGE_TAG}#g" docker-compose.yaml + # sed -i "s#image: opea/chatqna-ui:latest#image: opea/chatqna-ui:${IMAGE_TAG}#g" docker-compose.yaml + # sed -i "s#image: opea/*#image: ${IMAGE_REPO}opea/#g" docker-compose.yaml # Start Docker Containers - docker compose -f docker_compose.yaml up -d - n=0 - until [[ "$n" -ge 500 ]]; do - docker logs tgi-gaudi-server > $LOG_PATH/tgi_service_start.log - if grep -q Connected $LOG_PATH/tgi_service_start.log; then - break - fi - sleep 1s - n=$((n+1)) - done + docker compose down --remove-orphans + docker compose up -d + # n=0 + # until [[ "$n" -ge 200 ]]; do + # docker logs tgi-gaudi-server > tgi_service_start.log + # if grep -q Connected tgi_service_start.log; then + # break + # fi + # sleep 1s + # n=$((n+1)) + # done + sleep 8m } @@ -123,26 +105,23 @@ function validate_megaservice() { # fi #} -function stop_docker() { - cd $WORKPATH/docker/gaudi - container_list=$(cat docker_compose.yaml | grep container_name | cut -d':' -f2) - for container_name in $container_list; do - cid=$(docker ps -aq --filter "name=$container_name") - if [[ ! -z "$cid" ]]; then docker stop $cid && docker rm $cid && sleep 1s; fi - done -} - function main() { +<<<<<<< HEAD + # begin_time=$(date +%s) + build_docker_images + # start_time=$(date +%s) +======= stop_docker if [[ "$IMAGE_REPO" == "" ]]; then build_docker_images; fi +>>>>>>> source/main start_services # validate_microservices validate_megaservice # validate_frontend - stop_docker + docker compose down echo y | docker system prune } diff --git a/AudioQnA/tests/test_audioqna_on_xeon.sh b/AudioQnA/tests/test_audioqna_on_xeon.sh index d80c6ded1..0b14fa8c6 100644 --- a/AudioQnA/tests/test_audioqna_on_xeon.sh +++ b/AudioQnA/tests/test_audioqna_on_xeon.sh @@ -11,19 +11,7 @@ ip_address=$(hostname -I | awk '{print $1}') function build_docker_images() { cd $WORKPATH - git clone https://github.com/opea-project/GenAIComps.git - cd GenAIComps - - docker build -t opea/whisper:latest -f comps/asr/whisper/Dockerfile . - docker build -t opea/asr:latest -f comps/asr/Dockerfile . - docker build -t opea/llm-tgi:latest -f comps/llms/text-generation/tgi/Dockerfile . - docker build -t opea/speecht5:latest -f comps/tts/speecht5/Dockerfile . - docker build -t opea/tts:latest -f comps/tts/Dockerfile . - - docker pull ghcr.io/huggingface/tgi-gaudi:2.0.1 - - cd $WORKPATH/docker - docker build --no-cache -t opea/audioqna:latest -f Dockerfile . + docker compose build # cd $WORKPATH/docker/ui # docker build --no-cache -t opea/audioqna-ui:latest -f docker/Dockerfile . @@ -49,29 +37,9 @@ function start_services() { export TTS_SERVICE_PORT=3002 export LLM_SERVICE_PORT=3007 - # sed -i "s/backend_address/$ip_address/g" $WORKPATH/docker/ui/svelte/.env - - if [[ "$IMAGE_REPO" != "" ]]; then - # Replace the container name with a test-specific name - echo "using image repository $IMAGE_REPO and image tag $IMAGE_TAG" - sed -i "s#image: opea/audioqna:latest#image: opea/audioqna:${IMAGE_TAG}#g" docker_compose.yaml - sed -i "s#image: opea/audioqna-ui:latest#image: opea/audioqna-ui:${IMAGE_TAG}#g" docker_compose.yaml - sed -i "s#image: opea/*#image: ${IMAGE_REPO}opea/#g" docker_compose.yaml - echo "cat docker_compose.yaml" - cat docker_compose.yaml - fi - - # Start Docker Containers - docker compose -f docker_compose.yaml up -d - n=0 - until [[ "$n" -ge 200 ]]; do - docker logs tgi-service > $LOG_PATH/tgi_service_start.log - if grep -q Connected $LOG_PATH/tgi_service_start.log; then - break - fi - sleep 1s - n=$((n+1)) - done + docker compose down --remove-orphans + docker compose up -d + sleep 3m } @@ -111,25 +79,16 @@ function validate_megaservice() { # fi #} -function stop_docker() { - cd $WORKPATH/docker/xeon - container_list=$(cat docker_compose.yaml | grep container_name | cut -d':' -f2) - for container_name in $container_list; do - cid=$(docker ps -aq --filter "name=$container_name") - if [[ ! -z "$cid" ]]; then docker stop $cid && docker rm $cid && sleep 1s; fi - done -} - function main() { - stop_docker - if [[ "$IMAGE_REPO" == "" ]]; then build_docker_images; fi + build_docker_images + # begin_time=$(date +%s) start_services validate_megaservice # validate_frontend - stop_docker + docker compose down echo y | docker system prune }