Skip to content

Commit

Permalink
Enable nginx for VisualQnA (#754)
Browse files Browse the repository at this point in the history
Signed-off-by: lvliang-intel <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
lvliang-intel and pre-commit-ci[bot] committed Sep 9, 2024
1 parent ebe6b47 commit def19b4
Show file tree
Hide file tree
Showing 10 changed files with 267 additions and 3 deletions.
6 changes: 6 additions & 0 deletions VisualQnA/docker/docker_build_compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,9 @@ services:
dockerfile: comps/lvms/Dockerfile_tgi
extends: visualqna
image: ${REGISTRY:-opea}/lvm-tgi:${TAG:-latest}
nginx:
build:
context: GenAIComps
dockerfile: comps/nginx/docker/Dockerfile
extends: visualqna
image: ${REGISTRY:-opea}/nginx:${TAG:-latest}
19 changes: 19 additions & 0 deletions VisualQnA/docker/gaudi/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,25 @@ services:
- BACKEND_BASE_URL=${BACKEND_SERVICE_ENDPOINT}
ipc: host
restart: always
visualqna-gaudi-nginx-server:
image: ${REGISTRY:-opea}/nginx:${TAG:-latest}
container_name: visualqna-gaudi-nginx-server
depends_on:
- visualqna-gaudi-backend-server
- visualqna-gaudi-ui-server
ports:
- "${NGINX_PORT:-80}:80"
environment:
- no_proxy=${no_proxy}
- https_proxy=${https_proxy}
- http_proxy=${http_proxy}
- FRONTEND_SERVICE_IP=${FRONTEND_SERVICE_IP}
- FRONTEND_SERVICE_PORT=${FRONTEND_SERVICE_PORT}
- BACKEND_SERVICE_NAME=${BACKEND_SERVICE_NAME}
- BACKEND_SERVICE_IP=${BACKEND_SERVICE_IP}
- BACKEND_SERVICE_PORT=${BACKEND_SERVICE_PORT}
ipc: host
restart: always

networks:
default:
Expand Down
5 changes: 5 additions & 0 deletions VisualQnA/docker/gaudi/set_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ export LVM_SERVICE_PORT=9399
export MEGA_SERVICE_HOST_IP=${host_ip}
export LVM_SERVICE_HOST_IP=${host_ip}
export BACKEND_SERVICE_ENDPOINT="http://${host_ip}:8888/v1/visualqna"
export FRONTEND_SERVICE_IP=${host_ip}
export FRONTEND_SERVICE_PORT=5173
export BACKEND_SERVICE_NAME=visualqna
export BACKEND_SERVICE_IP=${host_ip}
export BACKEND_SERVICE_PORT=8888
2 changes: 1 addition & 1 deletion VisualQnA/docker/ui/svelte/.env
Original file line number Diff line number Diff line change
@@ -1 +1 @@
BACKEND_BASE_URL = 'http://backend_address:8888/v1/visualqna'
BACKEND_BASE_URL = '/v1/visualqna'
19 changes: 19 additions & 0 deletions VisualQnA/docker/xeon/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,25 @@ services:
- BACKEND_BASE_URL=${BACKEND_SERVICE_ENDPOINT}
ipc: host
restart: always
visualqna-xeon-nginx-server:
image: ${REGISTRY:-opea}/nginx:${TAG:-latest}
container_name: visualqna-xeon-nginx-server
depends_on:
- visualqna-xeon-backend-server
- visualqna-xeon-ui-server
ports:
- "${NGINX_PORT:-80}:80"
environment:
- no_proxy=${no_proxy}
- https_proxy=${https_proxy}
- http_proxy=${http_proxy}
- FRONTEND_SERVICE_IP=${FRONTEND_SERVICE_IP}
- FRONTEND_SERVICE_PORT=${FRONTEND_SERVICE_PORT}
- BACKEND_SERVICE_NAME=${BACKEND_SERVICE_NAME}
- BACKEND_SERVICE_IP=${BACKEND_SERVICE_IP}
- BACKEND_SERVICE_PORT=${BACKEND_SERVICE_PORT}
ipc: host
restart: always

networks:
default:
Expand Down
5 changes: 5 additions & 0 deletions VisualQnA/docker/xeon/set_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ export LVM_SERVICE_PORT=9399
export MEGA_SERVICE_HOST_IP=${host_ip}
export LVM_SERVICE_HOST_IP=${host_ip}
export BACKEND_SERVICE_ENDPOINT="http://${host_ip}:8888/v1/visualqna"
export FRONTEND_SERVICE_IP=${host_ip}
export FRONTEND_SERVICE_PORT=5173
export BACKEND_SERVICE_NAME=visualqna
export BACKEND_SERVICE_IP=${host_ip}
export BACKEND_SERVICE_PORT=8888
72 changes: 72 additions & 0 deletions VisualQnA/kubernetes/manifests/gaudi/visualqna.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -296,3 +296,75 @@ spec:
volumes:
- name: tmp
emptyDir: {}
---
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

apiVersion: v1
kind: ConfigMap
metadata:
name: visualqna-nginx-config
data:
default.conf: |
server {
listen 80;
listen [::]:80;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
location /v1/visualqna {
proxy_pass http://visualqna:8888;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
---
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

apiVersion: apps/v1
kind: Deployment
metadata:
name: visualqna-nginx-deployment
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:latest
ports:
- containerPort: 80
volumeMounts:
- name: nginx-config-volume
mountPath: /etc/nginx/conf.d/default.conf
subPath: default.conf
volumes:
- name: nginx-config-volume
configMap:
name: visualqna-nginx-config
---
kind: Service
apiVersion: v1
metadata:
name: nginx-svc
spec:
selector:
app: nginx
ports:
- protocol: TCP
port: 80
targetPort: 80
nodePort: 30789
type: NodePort
72 changes: 72 additions & 0 deletions VisualQnA/kubernetes/manifests/xeon/visualqna.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -296,3 +296,75 @@ spec:
volumes:
- name: tmp
emptyDir: {}
---
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

apiVersion: v1
kind: ConfigMap
metadata:
name: visualqna-nginx-config
data:
default.conf: |
server {
listen 80;
listen [::]:80;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
location /v1/visualqna {
proxy_pass http://visualqna:8888;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
---
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

apiVersion: apps/v1
kind: Deployment
metadata:
name: visualqna-nginx-deployment
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:latest
ports:
- containerPort: 80
volumeMounts:
- name: nginx-config-volume
mountPath: /etc/nginx/conf.d/default.conf
subPath: default.conf
volumes:
- name: nginx-config-volume
configMap:
name: visualqna-nginx-config
---
kind: Service
apiVersion: v1
metadata:
name: nginx-svc
spec:
selector:
app: nginx
ports:
- protocol: TCP
port: 80
targetPort: 80
nodePort: 30789
type: NodePort
35 changes: 34 additions & 1 deletion VisualQnA/tests/test_visualqna_on_gaudi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function build_docker_images() {
git clone https://github.com/opea-project/GenAIComps.git

echo "Build all the images with --no-cache, check docker_image_build.log for details..."
service_list="visualqna visualqna-ui llm-visualqna-tgi"
service_list="visualqna visualqna-ui llm-visualqna-tgi nginx"
docker compose -f docker_build_compose.yaml build ${service_list} --no-cache > ${LOG_PATH}/docker_image_build.log

docker pull ghcr.io/huggingface/tgi-gaudi:2.0.4
Expand All @@ -36,6 +36,12 @@ function start_services() {
export MEGA_SERVICE_HOST_IP=${ip_address}
export LVM_SERVICE_HOST_IP=${ip_address}
export BACKEND_SERVICE_ENDPOINT="http://${ip_address}:8888/v1/visualqna"
export FRONTEND_SERVICE_IP=${ip_address}
export FRONTEND_SERVICE_PORT=5173
export BACKEND_SERVICE_NAME=visualqna
export BACKEND_SERVICE_IP=${ip_address}
export BACKEND_SERVICE_PORT=8888
export NGINX_PORT=80

sed -i "s/backend_address/$ip_address/g" $WORKPATH/docker/ui/svelte/.env

Expand Down Expand Up @@ -120,6 +126,33 @@ function validate_megaservice() {
],
"max_tokens": 300
}'

# test the megeservice via nginx
validate_services \
"${ip_address}:80/v1/visualqna" \
"The image" \
"visualqna-gaudi-nginx-server" \
"visualqna-gaudi-nginx-server" \
'{
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "What'\''s in this image?"
},
{
"type": "image_url",
"image_url": {
"url": "https://www.ilankelman.org/stopsigns/australia.jpg"
}
}
]
}
],
"max_tokens": 300
}'
}

function validate_frontend() {
Expand Down
35 changes: 34 additions & 1 deletion VisualQnA/tests/test_visualqna_on_xeon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function build_docker_images() {
git clone https://github.com/opea-project/GenAIComps.git

echo "Build all the images with --no-cache, check docker_image_build.log for details..."
service_list="visualqna visualqna-ui llm-visualqna-tgi"
service_list="visualqna visualqna-ui llm-visualqna-tgi nginx"
docker compose -f docker_build_compose.yaml build ${service_list} --no-cache > ${LOG_PATH}/docker_image_build.log

docker pull ghcr.io/huggingface/text-generation-inference:2.2.0
Expand All @@ -36,6 +36,12 @@ function start_services() {
export MEGA_SERVICE_HOST_IP=${ip_address}
export LVM_SERVICE_HOST_IP=${ip_address}
export BACKEND_SERVICE_ENDPOINT="http://${ip_address}:8888/v1/visualqna"
export FRONTEND_SERVICE_IP=${ip_address}
export FRONTEND_SERVICE_PORT=5173
export BACKEND_SERVICE_NAME=visualqna
export BACKEND_SERVICE_IP=${ip_address}
export BACKEND_SERVICE_PORT=8888
export NGINX_PORT=80

sed -i "s/backend_address/$ip_address/g" $WORKPATH/docker/ui/svelte/.env

Expand Down Expand Up @@ -120,6 +126,33 @@ function validate_megaservice() {
],
"max_tokens": 300
}'

# test the megeservice via nginx
validate_services \
"${ip_address}:80/v1/visualqna" \
"The image" \
"visualqna-xeon-nginx-server" \
"visualqna-xeon-nginx-server" \
'{
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "What'\''s in this image?"
},
{
"type": "image_url",
"image_url": {
"url": "https://www.ilankelman.org/stopsigns/australia.jpg"
}
}
]
}
],
"max_tokens": 300
}'
}

function validate_frontend() {
Expand Down

0 comments on commit def19b4

Please sign in to comment.