Skip to content

Commit 9923135

Browse files
author
Theresa
authored
Make text2sql service endpoint configurable at runtime. (#2067)
Signed-off-by: ichbinblau <theresa.shan@intel.com>
1 parent 8ce8cf0 commit 9923135

5 files changed

Lines changed: 24 additions & 5 deletions

File tree

DBQnA/docker_compose/intel/cpu/xeon/compose.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ services:
66
image: ghcr.io/huggingface/text-generation-inference:2.4.0-intel-cpu
77
container_name: tgi-service
88
ports:
9-
- "8008:80"
9+
- "${TGI_PORT}:80"
1010
volumes:
1111
- "${MODEL_CACHE:-./data}:/data"
1212
environment:
@@ -35,7 +35,7 @@ services:
3535
image: ${REGISTRY:-opea}/text2sql:${TAG:-latest}
3636
container_name: text2sql-service
3737
ports:
38-
- "9090:8080"
38+
- "${TEXT2SQL_PORT}:8080"
3939
environment:
4040
- TGI_LLM_ENDPOINT=${TGI_LLM_ENDPOINT}
4141

@@ -50,6 +50,7 @@ services:
5050
- no_proxy=${no_proxy}
5151
- https_proxy=${https_proxy}
5252
- http_proxy=${http_proxy}
53+
- APP_TEXT_TO_SQL_URL=http://${host_ip}:${TEXT2SQL_PORT}/v1
5354
ipc: host
5455
restart: always
5556

DBQnA/ui/docker/Dockerfile.react

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ EXPOSE 80
2929

3030
COPY --from=vite-app /usr/app/react/dist /usr/share/nginx/html
3131
COPY --from=vite-app /usr/app/react/nginx.conf /etc/nginx/conf.d/default.conf
32+
COPY --chmod=0755 ./react/env.sh /docker-entrypoint.d/env.sh
3233

33-
ENTRYPOINT ["nginx", "-g", "daemon off;"]
34+
ENTRYPOINT ["/docker-entrypoint.d/env.sh"]

DBQnA/ui/react/.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VITE_TEXT_TO_SQL_URL=${TEXT_TO_SQL_URL}
1+
VITE_TEXT_TO_SQL_URL=APP_TEXT_TO_SQL_URL

DBQnA/ui/react/env.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/sh
2+
# Copyright (C) 2024 Intel Corporation
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
for i in $(env | grep APP_) #// Make sure to use the prefix MY_APP_ if you have any other prefix in env.production file variable name replace it with MY_APP_
6+
do
7+
key=$(echo $i | cut -d '=' -f 1)
8+
value=$(echo $i | cut -d '=' -f 2-)
9+
echo $key=$value
10+
# sed All files
11+
# find /usr/share/nginx/html -type f -exec sed -i "s|${key}|${value}|g" '{}' +
12+
# sed JS and CSS only
13+
find /usr/share/nginx/html -type f \( -name '*.js' -o -name '*.css' \) -exec sed -i "s|${key}|${value}|g" '{}' +
14+
done
15+
16+
# Start NGINX in the foreground
17+
nginx -g "daemon off;"

DBQnA/ui/react/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default defineConfig({
2424
},
2525
define: {
2626
// Dynamically set the hostname for the VITE_TEXT_TO_SQL_URL
27-
"import.meta.env.VITE_TEXT_TO_SQL_URL": JSON.stringify(`http://${process.env.TEXT_TO_SQL_URL}`),
27+
//"import.meta.env.VITE_TEXT_TO_SQL_URL": JSON.stringify(`http://${process.env.TEXT_TO_SQL_URL}`),
2828
"import.meta.env": process.env,
2929
},
3030
});

0 commit comments

Comments
 (0)