KevinHuSh commited on
Commit
b47e49a
·
1 Parent(s): 06526fb

docker debugging modification (#82)

Browse files
Dockerfile CHANGED
@@ -1,14 +1,20 @@
1
  FROM infiniflow/ragflow-base:v1.0
 
2
 
3
  WORKDIR /ragflow
4
 
5
- COPY . ./
6
- RUN cd ./web && npm i && npm build
7
 
8
- ENV PYTHONPATH=/ragflow
 
 
 
 
 
9
  ENV HF_ENDPOINT=https://hf-mirror.com
10
 
11
- COPY docker/entrypoint.sh ./
12
  RUN chmod +x ./entrypoint.sh
13
 
14
- ENTRYPOINT ["/bin/bash", "./entrypoint.sh"]
 
1
  FROM infiniflow/ragflow-base:v1.0
2
+ USER root
3
 
4
  WORKDIR /ragflow
5
 
6
+ ADD ./web ./web
7
+ RUN cd ./web && npm i && npm run build
8
 
9
+ ADD ./api ./api
10
+ ADD ./conf ./conf
11
+ ADD ./deepdoc ./deepdoc
12
+ ADD ./rag ./rag
13
+
14
+ ENV PYTHONPATH=/ragflow/
15
  ENV HF_ENDPOINT=https://hf-mirror.com
16
 
17
+ ADD docker/entrypoint.sh ./entrypoint.sh
18
  RUN chmod +x ./entrypoint.sh
19
 
20
+ ENTRYPOINT ["./entrypoint.sh"]
api/db/init_data.py CHANGED
@@ -66,7 +66,7 @@ def init_superuser():
66
  chat_mdl = LLMBundle(tenant["id"], LLMType.CHAT, tenant["llm_id"])
67
  msg = chat_mdl.chat(system="", history=[{"role": "user", "content": "Hello!"}], gen_conf={})
68
  if msg.find("ERROR: ") == 0:
69
- print("\33[91m【ERROR】\33[0m: ", "'{}' dosen't work. {}".format(tenant["llm_id"]), msg)
70
  embd_mdl = LLMBundle(tenant["id"], LLMType.EMBEDDING, tenant["embd_id"])
71
  v, c = embd_mdl.encode(["Hello!"])
72
  if c == 0:
 
66
  chat_mdl = LLMBundle(tenant["id"], LLMType.CHAT, tenant["llm_id"])
67
  msg = chat_mdl.chat(system="", history=[{"role": "user", "content": "Hello!"}], gen_conf={})
68
  if msg.find("ERROR: ") == 0:
69
+ print("\33[91m【ERROR】\33[0m: ", "'{}' dosen't work. {}".format(tenant["llm_id"], msg))
70
  embd_mdl = LLMBundle(tenant["id"], LLMType.EMBEDDING, tenant["embd_id"])
71
  v, c = embd_mdl.encode(["Hello!"])
72
  if c == 0:
docker/docker-compose.yml CHANGED
@@ -19,13 +19,19 @@ services:
19
  memlock:
20
  soft: -1
21
  hard: -1
 
 
 
 
 
22
  networks:
23
  - ragflow
24
  restart: always
25
 
26
  kibana:
27
- depends_on:
28
- - es01
 
29
  image: docker.elastic.co/kibana/kibana:${STACK_VERSION}
30
  container_name: ragflow-kibana
31
  volumes:
@@ -60,10 +66,10 @@ services:
60
  networks:
61
  - ragflow
62
  healthcheck:
63
- test: [ "CMD-SHELL", "curl --silent localhost:3306 >/dev/null || exit 1" ]
64
- interval: 10s
65
- timeout: 10s
66
- retries: 3
67
  restart: always
68
 
69
 
@@ -86,17 +92,20 @@ services:
86
 
87
  ragflow:
88
  depends_on:
89
- - es01
90
- - mysql
91
- - minio
 
92
  image: infiniflow/ragflow:v1.0
93
  container_name: ragflow-server
94
  ports:
95
  - ${SVR_HTTP_PORT}:9380
 
 
96
  volumes:
97
  - ./service_conf.yaml:/ragflow/conf/service_conf.yaml
98
- - ./nginx.conf:/etc/nginx/nginx.conf
99
  - ./ragflow-logs:/ragflow/logs
 
100
  networks:
101
  - ragflow
102
  restart: always
 
19
  memlock:
20
  soft: -1
21
  hard: -1
22
+ healthcheck:
23
+ test: ["CMD-SHELL", "curl http://localhost:9200"]
24
+ interval: 10s
25
+ timeout: 10s
26
+ retries: 120
27
  networks:
28
  - ragflow
29
  restart: always
30
 
31
  kibana:
32
+ depends_on:
33
+ es01:
34
+ condition: service_healthy
35
  image: docker.elastic.co/kibana/kibana:${STACK_VERSION}
36
  container_name: ragflow-kibana
37
  volumes:
 
66
  networks:
67
  - ragflow
68
  healthcheck:
69
+ test: ["CMD", "mysqladmin" ,"ping", "-uroot", "-p${MYSQL_PASSWORD}"]
70
+ interval: 10s
71
+ timeout: 10s
72
+ retries: 3
73
  restart: always
74
 
75
 
 
92
 
93
  ragflow:
94
  depends_on:
95
+ mysql:
96
+ condition: service_healthy
97
+ es01:
98
+ condition: service_healthy
99
  image: infiniflow/ragflow:v1.0
100
  container_name: ragflow-server
101
  ports:
102
  - ${SVR_HTTP_PORT}:9380
103
+ - 80:80
104
+ - 443:443
105
  volumes:
106
  - ./service_conf.yaml:/ragflow/conf/service_conf.yaml
 
107
  - ./ragflow-logs:/ragflow/logs
108
+ - ./nginx.conf:/etc/nginx/conf.d/ragflow.conf
109
  networks:
110
  - ragflow
111
  restart: always
docker/entrypoint.sh CHANGED
@@ -1,24 +1,34 @@
1
  #!/bin/bash
2
 
3
- python rag/svr/task_broker.py &
 
 
 
 
 
 
4
 
5
  function task_exe(){
6
- while [ 1 -eq 1 ];do mpirun -n 2 python rag/svr/task_executor.py ; done
 
7
  }
8
 
9
  function watch_broker(){
10
- while [ 1 -eq 1];do
11
  C=`ps aux|grep "task_broker.py"|grep -v grep|wc -l`;
12
  if [ $C -lt 1 ];then
13
- python rag/svr/task_broker.py &
14
  fi
15
  sleep 5;
16
  done
17
  }
18
 
 
 
 
 
19
 
 
20
  task_exe &
21
- sleep 10;
22
- watch_broker &
23
 
24
- python api/ragflow_server.py
 
1
  #!/bin/bash
2
 
3
+ /usr/sbin/nginx
4
+
5
+ export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/
6
+
7
+ PY=/root/miniconda3/envs/py11/bin/python
8
+
9
+
10
 
11
  function task_exe(){
12
+ sleep 60;
13
+ while [ 1 -eq 1 ];do mpirun -n 2 --allow-run-as-root $PY rag/svr/task_executor.py ; done
14
  }
15
 
16
  function watch_broker(){
17
+ while [ 1 -eq 1 ];do
18
  C=`ps aux|grep "task_broker.py"|grep -v grep|wc -l`;
19
  if [ $C -lt 1 ];then
20
+ $PY rag/svr/task_broker.py &
21
  fi
22
  sleep 5;
23
  done
24
  }
25
 
26
+ function task_bro(){
27
+ sleep 60;
28
+ watch_broker;
29
+ }
30
 
31
+ task_bro &
32
  task_exe &
 
 
33
 
34
+ $PY api/ragflow_server.py
docker/nginx.conf CHANGED
@@ -1,46 +1,46 @@
1
- upstream api_service {
2
- server 127.0.0.1:9380;
3
- keepalive 2000;
4
- }
5
-
6
- server {
7
- listen 5101;
8
- # server_name xxx.com;
9
-
10
- # gzip config
11
- gzip on;
12
- gzip_min_length 1k;
13
- gzip_comp_level 9;
14
- gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
15
- gzip_vary on;
16
- gzip_disable "MSIE [1-6]\.";
17
-
18
-
19
- # remove api server header
20
- proxy_hide_header Access-Control-Allow-Origin;
21
- proxy_hide_header Access-Control-Allow-Methods;
22
- proxy_hide_header Access-Control-Allow-Headers;
23
-
24
- root /ragflow/web/dist;
25
-
26
- location / {
27
- index index.html;
28
- try_files $uri $uri/ /index.html;
29
- }
30
-
31
- # Cache-Control: max-age、Expires
32
- location ~ ^/static/(css|js|media)/ {
33
- expires 10y;
34
- access_log off;
35
- }
36
-
37
- # api proxy
38
- location ^~/v1 {
39
- rewrite ^/v1/(.*)$ /$1 break;
40
- proxy_pass http://api_service/;
41
- proxy_set_header Host $http_host;
42
- proxy_set_header Connection close;
43
- proxy_set_header X-Real-IP $remote_addr;
44
- proxy_set_header X-Forwarded-Server $host;
45
- }
46
- }
 
1
+ upstream api_service {
2
+ server ragflow:9380;
3
+ keepalive 2000;
4
+ }
5
+
6
+ server {
7
+ listen 80;
8
+ server_name ragflow.io;
9
+
10
+ # gzip config
11
+ gzip on;
12
+ gzip_min_length 1k;
13
+ gzip_comp_level 9;
14
+ gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
15
+ gzip_vary on;
16
+ gzip_disable "MSIE [1-6]\.";
17
+
18
+
19
+ # remove api server header
20
+ proxy_hide_header Access-Control-Allow-Origin;
21
+ proxy_hide_header Access-Control-Allow-Methods;
22
+ proxy_hide_header Access-Control-Allow-Headers;
23
+
24
+ root /ragflow/web/dist;
25
+
26
+ location / {
27
+ index index.html;
28
+ try_files $uri $uri/ /index.html;
29
+ }
30
+
31
+ # Cache-Control: max-age、Expires
32
+ location ~ ^/static/(css|js|media)/ {
33
+ expires 10y;
34
+ access_log off;
35
+ }
36
+
37
+ # api proxy
38
+ location ^~/v1 {
39
+ rewrite ^/v1/(.*)$ /$1 break;
40
+ proxy_pass http://api_service/;
41
+ proxy_set_header Host $http_host;
42
+ proxy_set_header Connection close;
43
+ proxy_set_header X-Real-IP $remote_addr;
44
+ proxy_set_header X-Forwarded-Server $host;
45
+ }
46
+ }
docker/service_conf.yaml CHANGED
@@ -5,16 +5,16 @@ mysql:
5
  name: 'rag_flow'
6
  user: 'root'
7
  password: 'infini_rag_flow'
8
- host: '127.0.0.1'
9
- port: 5455
10
  max_connections: 100
11
  stale_timeout: 30
12
  minio:
13
  user: 'rag_flow'
14
  password: 'infini_rag_flow'
15
- host: '127.0.0.1:9000'
16
  es:
17
- hosts: 'http://127.0.0.1:1200'
18
  user_default_llm:
19
  factory: '通义千问'
20
  api_key: 'sk-xxxxxxxxxxxxx'
 
5
  name: 'rag_flow'
6
  user: 'root'
7
  password: 'infini_rag_flow'
8
+ host: 'mysql'
9
+ port: 3306
10
  max_connections: 100
11
  stale_timeout: 30
12
  minio:
13
  user: 'rag_flow'
14
  password: 'infini_rag_flow'
15
+ host: 'minio:9000'
16
  es:
17
+ hosts: 'http://es01:9200'
18
  user_default_llm:
19
  factory: '通义千问'
20
  api_key: 'sk-xxxxxxxxxxxxx'
rag/svr/task_executor.py CHANGED
@@ -48,7 +48,7 @@ from api.utils.file_utils import get_project_base_directory
48
  BATCH_SIZE = 64
49
 
50
  FACTORY = {
51
- ParserType.GENERAL.value: manual,
52
  ParserType.PAPER.value: paper,
53
  ParserType.BOOK.value: book,
54
  ParserType.PRESENTATION.value: presentation,
 
48
  BATCH_SIZE = 64
49
 
50
  FACTORY = {
51
+ ParserType.GENERAL.value: laws,
52
  ParserType.PAPER.value: paper,
53
  ParserType.BOOK.value: book,
54
  ParserType.PRESENTATION.value: presentation,