From da80ea76b7df415ec7ecf42ae65a0a817faf80bb Mon Sep 17 00:00:00 2001 From: zstar <65890619+zstar1003@users.noreply.github.com> Date: Sun, 6 Apr 2025 00:54:39 +0800 Subject: [PATCH] =?UTF-8?q?refactor(docker):=20=E4=BF=AE=E6=94=B9readme.md?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8D=E8=8B=A5=E5=B9=B2=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E9=A1=B5=E9=9D=A2bug=20(#14)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/tests.yml | 170 +++++++++++++-------------- docker/docker-compose-CN-oc9.yml | 33 ------ docker/docker-compose-gpu-CN-oc9.yml | 40 ------- docker/docker-compose-gpu.yml | 40 ------- docker/docker-compose-macos.yml | 56 --------- docker/docker-compose.yml | 45 +++---- management/server/database.py | 4 +- 7 files changed, 110 insertions(+), 278 deletions(-) delete mode 100644 docker/docker-compose-CN-oc9.yml delete mode 100644 docker/docker-compose-gpu-CN-oc9.yml delete mode 100644 docker/docker-compose-gpu.yml delete mode 100644 docker/docker-compose-macos.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 43fb1b9..016498e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -53,101 +53,101 @@ jobs: version: ">=0.8.2" args: "check" - # - name: Build ragflow:nightly-slim - # run: | - # RUNNER_WORKSPACE_PREFIX=${RUNNER_WORKSPACE_PREFIX:-$HOME} - # sudo docker pull ubuntu:22.04 - # sudo docker build --progress=plain --build-arg LIGHTEN=1 --build-arg NEED_MIRROR=1 -f Dockerfile -t infiniflow/ragflow:nightly-slim . + - name: Build ragflow:nightly-slim + run: | + RUNNER_WORKSPACE_PREFIX=${RUNNER_WORKSPACE_PREFIX:-$HOME} + sudo docker pull ubuntu:22.04 + sudo docker build --progress=plain --build-arg LIGHTEN=1 --build-arg NEED_MIRROR=1 -f Dockerfile -t infiniflow/ragflow:nightly-slim . - # - name: Build ragflow:nightly - # run: | - # sudo docker build --progress=plain --build-arg NEED_MIRROR=1 -f Dockerfile -t infiniflow/ragflow:nightly . + - name: Build ragflow:nightly + run: | + sudo docker build --progress=plain --build-arg NEED_MIRROR=1 -f Dockerfile -t infiniflow/ragflow:nightly . - # - name: Start ragflow:nightly-slim - # run: | - # echo -e "\nRAGFLOW_IMAGE=infiniflow/ragflow:nightly-slim" >> docker/.env - # sudo docker compose -f docker/docker-compose.yml up -d + - name: Start ragflow:nightly-slim + run: | + echo -e "\nRAGFLOW_IMAGE=infiniflow/ragflow:nightly-slim" >> docker/.env + sudo docker compose -f docker/docker-compose.yml up -d - # - name: Stop ragflow:nightly-slim - # if: always() # always run this step even if previous steps failed - # run: | - # sudo docker compose -f docker/docker-compose.yml down -v + - name: Stop ragflow:nightly-slim + if: always() # always run this step even if previous steps failed + run: | + sudo docker compose -f docker/docker-compose.yml down -v - # - name: Start ragflow:nightly - # run: | - # echo -e "\nRAGFLOW_IMAGE=infiniflow/ragflow:nightly" >> docker/.env - # sudo docker compose -f docker/docker-compose.yml up -d + - name: Start ragflow:nightly + run: | + echo -e "\nRAGFLOW_IMAGE=infiniflow/ragflow:nightly" >> docker/.env + sudo docker compose -f docker/docker-compose.yml up -d - # - name: Run sdk tests against Elasticsearch - # run: | - # export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY="" - # export HOST_ADDRESS=http://host.docker.internal:9380 - # until sudo docker exec ragflow-server curl -s --connect-timeout 5 ${HOST_ADDRESS} > /dev/null; do - # echo "Waiting for service to be available..." - # sleep 5 - # done - # cd sdk/python && uv sync --python 3.10 --frozen && uv pip install . && source .venv/bin/activate && cd test/test_sdk_api && pytest -s --tb=short get_email.py t_dataset.py t_chat.py t_session.py t_document.py t_chunk.py + - name: Run sdk tests against Elasticsearch + run: | + export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY="" + export HOST_ADDRESS=http://host.docker.internal:9380 + until sudo docker exec ragflow-server curl -s --connect-timeout 5 ${HOST_ADDRESS} > /dev/null; do + echo "Waiting for service to be available..." + sleep 5 + done + cd sdk/python && uv sync --python 3.10 --frozen && uv pip install . && source .venv/bin/activate && cd test/test_sdk_api && pytest -s --tb=short get_email.py t_dataset.py t_chat.py t_session.py t_document.py t_chunk.py - # - name: Run frontend api tests against Elasticsearch - # run: | - # export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY="" - # export HOST_ADDRESS=http://host.docker.internal:9380 - # until sudo docker exec ragflow-server curl -s --connect-timeout 5 ${HOST_ADDRESS} > /dev/null; do - # echo "Waiting for service to be available..." - # sleep 5 - # done - # cd sdk/python && uv sync --python 3.10 --frozen && uv pip install . && source .venv/bin/activate && cd test/test_frontend_api && pytest -s --tb=short get_email.py test_dataset.py + - name: Run frontend api tests against Elasticsearch + run: | + export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY="" + export HOST_ADDRESS=http://host.docker.internal:9380 + until sudo docker exec ragflow-server curl -s --connect-timeout 5 ${HOST_ADDRESS} > /dev/null; do + echo "Waiting for service to be available..." + sleep 5 + done + cd sdk/python && uv sync --python 3.10 --frozen && uv pip install . && source .venv/bin/activate && cd test/test_frontend_api && pytest -s --tb=short get_email.py test_dataset.py - # - name: Run http api tests against Elasticsearch - # run: | - # export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY="" - # export HOST_ADDRESS=http://host.docker.internal:9380 - # until sudo docker exec ragflow-server curl -s --connect-timeout 5 ${HOST_ADDRESS} > /dev/null; do - # echo "Waiting for service to be available..." - # sleep 5 - # done - # cd sdk/python && uv sync --python 3.10 --frozen && uv pip install . && source .venv/bin/activate && cd test/test_http_api && pytest -s --tb=short -m "not slow" + - name: Run http api tests against Elasticsearch + run: | + export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY="" + export HOST_ADDRESS=http://host.docker.internal:9380 + until sudo docker exec ragflow-server curl -s --connect-timeout 5 ${HOST_ADDRESS} > /dev/null; do + echo "Waiting for service to be available..." + sleep 5 + done + cd sdk/python && uv sync --python 3.10 --frozen && uv pip install . && source .venv/bin/activate && cd test/test_http_api && pytest -s --tb=short -m "not slow" - # - name: Stop ragflow:nightly - # if: always() # always run this step even if previous steps failed - # run: | - # sudo docker compose -f docker/docker-compose.yml down -v + - name: Stop ragflow:nightly + if: always() # always run this step even if previous steps failed + run: | + sudo docker compose -f docker/docker-compose.yml down -v - # - name: Start ragflow:nightly - # run: | - # sudo DOC_ENGINE=infinity docker compose -f docker/docker-compose.yml up -d + - name: Start ragflow:nightly + run: | + sudo DOC_ENGINE=infinity docker compose -f docker/docker-compose.yml up -d - # - name: Run sdk tests against Infinity - # run: | - # export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY="" - # export HOST_ADDRESS=http://host.docker.internal:9380 - # until sudo docker exec ragflow-server curl -s --connect-timeout 5 ${HOST_ADDRESS} > /dev/null; do - # echo "Waiting for service to be available..." - # sleep 5 - # done - # cd sdk/python && uv sync --python 3.10 --frozen && uv pip install . && source .venv/bin/activate && cd test/test_sdk_api && pytest -s --tb=short get_email.py t_dataset.py t_chat.py t_session.py t_document.py t_chunk.py + - name: Run sdk tests against Infinity + run: | + export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY="" + export HOST_ADDRESS=http://host.docker.internal:9380 + until sudo docker exec ragflow-server curl -s --connect-timeout 5 ${HOST_ADDRESS} > /dev/null; do + echo "Waiting for service to be available..." + sleep 5 + done + cd sdk/python && uv sync --python 3.10 --frozen && uv pip install . && source .venv/bin/activate && cd test/test_sdk_api && pytest -s --tb=short get_email.py t_dataset.py t_chat.py t_session.py t_document.py t_chunk.py - # - name: Run frontend api tests against Infinity - # run: | - # export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY="" - # export HOST_ADDRESS=http://host.docker.internal:9380 - # until sudo docker exec ragflow-server curl -s --connect-timeout 5 ${HOST_ADDRESS} > /dev/null; do - # echo "Waiting for service to be available..." - # sleep 5 - # done - # cd sdk/python && uv sync --python 3.10 --frozen && uv pip install . && source .venv/bin/activate && cd test/test_frontend_api && pytest -s --tb=short get_email.py test_dataset.py + - name: Run frontend api tests against Infinity + run: | + export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY="" + export HOST_ADDRESS=http://host.docker.internal:9380 + until sudo docker exec ragflow-server curl -s --connect-timeout 5 ${HOST_ADDRESS} > /dev/null; do + echo "Waiting for service to be available..." + sleep 5 + done + cd sdk/python && uv sync --python 3.10 --frozen && uv pip install . && source .venv/bin/activate && cd test/test_frontend_api && pytest -s --tb=short get_email.py test_dataset.py - # - name: Run http api tests against Infinity - # run: | - # export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY="" - # export HOST_ADDRESS=http://host.docker.internal:9380 - # until sudo docker exec ragflow-server curl -s --connect-timeout 5 ${HOST_ADDRESS} > /dev/null; do - # echo "Waiting for service to be available..." - # sleep 5 - # done - # cd sdk/python && uv sync --python 3.10 --frozen && uv pip install . && source .venv/bin/activate && cd test/test_http_api && DOC_ENGINE=infinity pytest -s --tb=short -m "not slow" + - name: Run http api tests against Infinity + run: | + export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY="" + export HOST_ADDRESS=http://host.docker.internal:9380 + until sudo docker exec ragflow-server curl -s --connect-timeout 5 ${HOST_ADDRESS} > /dev/null; do + echo "Waiting for service to be available..." + sleep 5 + done + cd sdk/python && uv sync --python 3.10 --frozen && uv pip install . && source .venv/bin/activate && cd test/test_http_api && DOC_ENGINE=infinity pytest -s --tb=short -m "not slow" - # - name: Stop ragflow:nightly - # if: always() # always run this step even if previous steps failed - # run: | - # sudo DOC_ENGINE=infinity docker compose -f docker/docker-compose.yml down -v + - name: Stop ragflow:nightly + if: always() # always run this step even if previous steps failed + run: | + sudo DOC_ENGINE=infinity docker compose -f docker/docker-compose.yml down -v diff --git a/docker/docker-compose-CN-oc9.yml b/docker/docker-compose-CN-oc9.yml deleted file mode 100644 index aa6bb3d..0000000 --- a/docker/docker-compose-CN-oc9.yml +++ /dev/null @@ -1,33 +0,0 @@ -# The RAGFlow team do not actively maintain docker-compose-CN-oc9.yml, so use them at your own risk. -# However, you are welcome to file a pull request to improve it. -include: - - ./docker-compose-base.yml - -services: - ragflow: - depends_on: - mysql: - condition: service_healthy - image: edwardelric233/ragflow:oc9 - container_name: ragflow-server - ports: - - ${SVR_HTTP_PORT}:9380 - - 80:80 - - 443:443 - volumes: - - ./ragflow-logs:/ragflow/logs - - ./nginx/ragflow.conf:/etc/nginx/conf.d/ragflow.conf - - ./nginx/proxy.conf:/etc/nginx/proxy.conf - - ./nginx/nginx.conf:/etc/nginx/nginx.conf - env_file: .env - environment: - - TZ=${TIMEZONE} - - HF_ENDPOINT=${HF_ENDPOINT} - - MACOS=${MACOS} - networks: - - ragflow - restart: on-failure - # https://docs.docker.com/engine/daemon/prometheus/#create-a-prometheus-configuration - # If you're using Docker Desktop, the --add-host flag is optional. This flag makes sure that the host's internal IP gets exposed to the Prometheus container. - extra_hosts: - - "host.docker.internal:host-gateway" diff --git a/docker/docker-compose-gpu-CN-oc9.yml b/docker/docker-compose-gpu-CN-oc9.yml deleted file mode 100644 index fb4213d..0000000 --- a/docker/docker-compose-gpu-CN-oc9.yml +++ /dev/null @@ -1,40 +0,0 @@ -# The RAGFlow team do not actively maintain docker-compose-gpu-CN-oc9.yml, so use them at your own risk. -# However, you are welcome to file a pull request to improve it. -include: - - ./docker-compose-base.yml - -services: - ragflow: - depends_on: - mysql: - condition: service_healthy - image: edwardelric233/ragflow:oc9 - container_name: ragflow-server - ports: - - ${SVR_HTTP_PORT}:9380 - - 80:80 - - 443:443 - volumes: - - ./ragflow-logs:/ragflow/logs - - ./nginx/ragflow.conf:/etc/nginx/conf.d/ragflow.conf - - ./nginx/proxy.conf:/etc/nginx/proxy.conf - - ./nginx/nginx.conf:/etc/nginx/nginx.conf - env_file: .env - environment: - - TZ=${TIMEZONE} - - HF_ENDPOINT=${HF_ENDPOINT} - - MACOS=${MACOS} - networks: - - ragflow - restart: on-failure - # https://docs.docker.com/engine/daemon/prometheus/#create-a-prometheus-configuration - # If you're using Docker Desktop, the --add-host flag is optional. This flag makes sure that the host's internal IP gets exposed to the Prometheus container. - extra_hosts: - - "host.docker.internal:host-gateway" - deploy: - resources: - reservations: - devices: - - driver: nvidia - count: all - capabilities: [gpu] diff --git a/docker/docker-compose-gpu.yml b/docker/docker-compose-gpu.yml deleted file mode 100644 index a878ed5..0000000 --- a/docker/docker-compose-gpu.yml +++ /dev/null @@ -1,40 +0,0 @@ -# The RAGFlow team do not actively maintain docker-compose-gpu.yml, so use them at your own risk. -# Pull requests to improve it are welcome. -include: - - ./docker-compose-base.yml - -services: - ragflow: - depends_on: - mysql: - condition: service_healthy - image: ${RAGFLOW_IMAGE} - container_name: ragflow-server - ports: - - ${SVR_HTTP_PORT}:9380 - - 80:80 - - 443:443 - volumes: - - ./ragflow-logs:/ragflow/logs - - ./nginx/ragflow.conf:/etc/nginx/conf.d/ragflow.conf - - ./nginx/proxy.conf:/etc/nginx/proxy.conf - - ./nginx/nginx.conf:/etc/nginx/nginx.conf - env_file: .env - environment: - - TZ=${TIMEZONE} - - HF_ENDPOINT=${HF_ENDPOINT} - - MACOS=${MACOS} - networks: - - ragflow - restart: on-failure - # https://docs.docker.com/engine/daemon/prometheus/#create-a-prometheus-configuration - # If you're using Docker Desktop, the --add-host flag is optional. This flag makes sure that the host's internal IP gets exposed to the Prometheus container. - extra_hosts: - - "host.docker.internal:host-gateway" - deploy: - resources: - reservations: - devices: - - driver: nvidia - count: all - capabilities: [gpu] diff --git a/docker/docker-compose-macos.yml b/docker/docker-compose-macos.yml deleted file mode 100644 index 4862c0e..0000000 --- a/docker/docker-compose-macos.yml +++ /dev/null @@ -1,56 +0,0 @@ -include: - - ./docker-compose-base.yml - -services: - ragflow: - depends_on: - mysql: - condition: service_healthy - build: - context: ../ - dockerfile: Dockerfile - container_name: ragflow-server - ports: - - ${SVR_HTTP_PORT}:9380 - - 80:80 - - 443:443 - volumes: - - ./ragflow-logs:/ragflow/logs - - ./nginx/ragflow.conf:/etc/nginx/conf.d/ragflow.conf - - ./nginx/proxy.conf:/etc/nginx/proxy.conf - - ./nginx/nginx.conf:/etc/nginx/nginx.conf - env_file: .env - environment: - - TZ=${TIMEZONE} - - HF_ENDPOINT=${HF_ENDPOINT} - - MACOS=${MACOS:-1} - - LIGHTEN=${LIGHTEN:-1} - networks: - - ragflow - restart: on-failure - # https://docs.docker.com/engine/daemon/prometheus/#create-a-prometheus-configuration - # If you're using Docker Desktop, the --add-host flag is optional. This flag makes sure that the host's internal IP gets exposed to the Prometheus container. - extra_hosts: - - "host.docker.internal:host-gateway" - # executor: - # depends_on: - # mysql: - # condition: service_healthy - # image: ${RAGFLOW_IMAGE} - # container_name: ragflow-executor - # volumes: - # - ./ragflow-logs:/ragflow/logs - # - ./nginx/ragflow.conf:/etc/nginx/conf.d/ragflow.conf - # env_file: .env - # environment: - # - TZ=${TIMEZONE} - # - HF_ENDPOINT=${HF_ENDPOINT} - # - MACOS=${MACOS} - # entrypoint: "/ragflow/entrypoint_task_executor.sh 1 3" - # networks: - # - ragflow - # restart: on-failure - # # https://docs.docker.com/engine/daemon/prometheus/#create-a-prometheus-configuration - # # If you're using Docker Desktop, the --add-host flag is optional. This flag makes sure that the host's internal IP gets exposed to the Prometheus container. - # extra_hosts: - # - "host.docker.internal:host-gateway" diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 676f167..b3fa364 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -29,25 +29,26 @@ services: # If you're using Docker Desktop, the --add-host flag is optional. This flag makes sure that the host's internal IP gets exposed to the Prometheus container. extra_hosts: - "host.docker.internal:host-gateway" - # executor: - # depends_on: - # mysql: - # condition: service_healthy - # image: ${RAGFLOW_IMAGE} - # container_name: ragflow-executor - # volumes: - # - ./ragflow-logs:/ragflow/logs - # - ./nginx/ragflow.conf:/etc/nginx/conf.d/ragflow.conf - # env_file: .env - # environment: - # - TZ=${TIMEZONE} - # - HF_ENDPOINT=${HF_ENDPOINT} - # - MACOS=${MACOS} - # entrypoint: "/ragflow/entrypoint_task_executor.sh 1 3" - # networks: - # - ragflow - # restart: on-failure - # # https://docs.docker.com/engine/daemon/prometheus/#create-a-prometheus-configuration - # # If you're using Docker Desktop, the --add-host flag is optional. This flag makes sure that the host's internal IP gets exposed to the Prometheus container. - # extra_hosts: - # - "host.docker.internal:host-gateway" + + management-frontend: + image: zstar1003/ragflowplus-management-web:v0.1.1 + ports: + - "8080:80" + depends_on: + - management-backend + environment: + - API_URL=http://management-backend:5000 + networks: + - ragflow + + management-backend: + image: zstar1003/ragflowplus-management-server:v0.1.1 + ports: + - "5000:5000" + environment: + - FLASK_ENV=development + - CORS_ALLOWED_ORIGINS=http://localhost:8080,http://management-frontend + extra_hosts: + - "host.docker.internal:host-gateway" + networks: + - ragflow \ No newline at end of file diff --git a/management/server/database.py b/management/server/database.py index d2aa5e3..b5aff8b 100644 --- a/management/server/database.py +++ b/management/server/database.py @@ -4,8 +4,8 @@ from datetime import datetime # 数据库连接配置 db_config = { - # "host": "host.docker.internal", 如果是在Docke容器内部访问数据库 - "host": "localhost", + "host": "host.docker.internal", # 如果是在Docke容器内部访问数据库 + # "host": "localhost", "port": 5455, "user": "root", "password": "infini_rag_flow",