From 7f1f496a30fea1f2480c79c4fcea5b1a8ca31a5f Mon Sep 17 00:00:00 2001 From: neos evo Date: Tue, 23 Apr 2024 14:05:22 +0800 Subject: [PATCH] support backgroud task --- client/Dockerfile.api | 5 ++++- client/Dockerfile.web | 4 +++- client/README.md | 3 +++ client/backend/docker_entrypoint.sh | 5 +++++ client/backend/requirements.txt | 3 ++- client/compose.yaml | 6 ++++-- client/env_sample | 16 ++++++++-------- 7 files changed, 29 insertions(+), 13 deletions(-) create mode 100644 client/backend/docker_entrypoint.sh diff --git a/client/Dockerfile.api b/client/Dockerfile.api index 01cf413..6ad45b1 100644 --- a/client/Dockerfile.api +++ b/client/Dockerfile.api @@ -13,4 +13,7 @@ RUN pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple COPY backend . EXPOSE 7777 -CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7777"] \ No newline at end of file + +CMD tail -f /dev/null + +# ENTRYPOINT ["bash", "docker_entrypoint.sh"] \ No newline at end of file diff --git a/client/Dockerfile.web b/client/Dockerfile.web index df59a6b..d6012d2 100644 --- a/client/Dockerfile.web +++ b/client/Dockerfile.web @@ -30,4 +30,6 @@ WORKDIR /pb EXPOSE 8090 -CMD ["/pb/pocketbase", "serve", "--http=0.0.0.0:8090"] +CMD tail -f /dev/null + +# CMD ["/pb/pocketbase", "serve", "--http=0.0.0.0:8090"] diff --git a/client/README.md b/client/README.md index 575fb2d..e829e75 100644 --- a/client/README.md +++ b/client/README.md @@ -21,6 +21,9 @@ ### 2、强烈建议普通用户 +- cd client +- 启动项目: docker compose up -d +- 关闭项目:docker compose down ### 3、管理配置页面 —— http://127.0.0.1:8090/_/ diff --git a/client/backend/docker_entrypoint.sh b/client/backend/docker_entrypoint.sh new file mode 100644 index 0000000..c5675ca --- /dev/null +++ b/client/backend/docker_entrypoint.sh @@ -0,0 +1,5 @@ +#!/bin/bash +set -o allexport +set +o allexport +exec uvicorn main:app --reload --host 0.0.0.0 --port 7777 & +exec python background_task.py \ No newline at end of file diff --git a/client/backend/requirements.txt b/client/backend/requirements.txt index 573c9a9..da55fb9 100644 --- a/client/backend/requirements.txt +++ b/client/backend/requirements.txt @@ -13,4 +13,5 @@ langsmith==0.0.77 faiss-cpu # for cpu-only environment pocketbase==0.10.0 gne -chardet \ No newline at end of file +chardet +schedule \ No newline at end of file diff --git a/client/compose.yaml b/client/compose.yaml index 0e51d87..e16e727 100755 --- a/client/compose.yaml +++ b/client/compose.yaml @@ -10,6 +10,7 @@ services: volumes: - ./pb/pb_data:/pb/pb_data # - ./${PROJECT_DIR}:/pb/${PROJECT_DIR} + entrypoint: /pb/pocketbase serve --http=0.0.0.0:8090 api: build: @@ -17,13 +18,14 @@ services: image: wiseflow/api tty: true stdin_open: true + entrypoint: bash docker_entrypoint.sh env_file: - .env ports: - 7777:7777 volumes: - ./${PROJECT_DIR}:/app/${PROJECT_DIR} - - ${EMBEDDING_MODEL_PATH}:${EMBEDDING_MODEL_PATH} - - ${RERANKER_MODEL_PATH}:${RERANKER_MODEL_PATH} + - ./${EMBEDDING_MODEL_PATH}:/app/${EMBEDDING_MODEL_PATH} + - ./${RERANKER_MODEL_PATH}:/app/${RERANKER_MODEL_PATH} depends_on: - web \ No newline at end of file diff --git a/client/env_sample b/client/env_sample index f3035e9..fff3579 100755 --- a/client/env_sample +++ b/client/env_sample @@ -1,14 +1,14 @@ #**for local llmp server** -export DASHSCOPE_API_KEY='' -export VOLC_KEY='AK|SK' +export DASHSCOPE_API_KEY="" +export VOLC_KEY="AK|SK" #**for embeddig model** -export EMBEDDING_MODEL_PATH='' -export RERANKER_MODEL_PATH='' -export DEVICE='' +export EMBEDDING_MODEL_PATH="bce-embedding-base_v1" +export RERANKER_MODEL_PATH="bce-reranker-base_v1" +export DEVICE="cpu" #**for processer** -export PROJECT_DIR="" +export PROJECT_DIR="work_dir" export WS_LOG="verbose" -export PB_API_AUTH='test@example.com|123467890' -export PB_API_BASE='web:8090' ##可以参考https://stackoverflow.com/questions/70151702/how-to-network-2-separate-docker-containers-to-communicate-with-eachother \ No newline at end of file +export PB_API_AUTH="test@example.com|123467890" +export PB_API_BASE="web:8090" ##可以参考https://stackoverflow.com/questions/70151702/how-to-network-2-separate-docker-containers-to-communicate-with-eachother \ No newline at end of file