7.31 将环境和后端前端放一个docker网络中

This commit is contained in:
zhangsan 2025-07-31 15:44:48 +08:00
parent 4e7d95cca1
commit 82f200e443
13 changed files with 95 additions and 12077 deletions

1
.gitignore vendored
View File

@ -50,3 +50,4 @@ build/
/docs/tag/v1.0/log/ /docs/tag/v1.0/log/
/docs/tag/v1.0/log/ /docs/tag/v1.0/log/
/docs/tag/rag-knowledge-v1.0/ollama/ /docs/tag/rag-knowledge-v1.0/ollama/
/docs/tag/rag-knowledge-v1.0/log/

View File

@ -1,12 +1,16 @@
server: server:
port: 8090 port: 8095
spring: spring:
servlet:
multipart:
max-file-size: 10MB
max-request-size: 200MB
datasource: datasource:
driver-class-name: org.postgresql.Driver driver-class-name: org.postgresql.Driver
username: postgres username: postgres
password: postgres password: postgres
url: jdbc:postgresql://192.168.1.109:15432/ai-rag-knowledge url: jdbc:postgresql://vector_db/ai-rag-knowledge
type: com.zaxxer.hikari.HikariDataSource type: com.zaxxer.hikari.HikariDataSource
# hikari连接池配置 # hikari连接池配置
hikari: hikari:
@ -28,15 +32,11 @@ spring:
connection-test-query: SELECT 1 connection-test-query: SELECT 1
ai: ai:
ollama: ollama:
base-url: http://192.168.1.109:11434 base-url: http://ollama:11434
embedding: embedding:
options: options:
num-batch: 512 num-batch: 512
model: nomic-embed-text model: nomic-embed-text
openai:
base-url: https://pro-share-aws-api.zcyai.com/
api-key: sk-eEyfxptPgbfXd3Z164260740E0494161Bd8**找小傅哥申请
embedding-model: text-embedding-ada-002
rag: rag:
embed: nomic-embed-text #nomic-embed-text、text-embedding-ada-002 embed: nomic-embed-text #nomic-embed-text、text-embedding-ada-002
@ -45,8 +45,8 @@ spring:
redis: redis:
sdk: sdk:
config: config:
host: 192.168.1.109 host: redis
port: 16379 port: 6379
pool-size: 10 pool-size: 10
min-idle-size: 5 min-idle-size: 5
idle-timeout: 30000 idle-timeout: 30000

View File

@ -2,4 +2,4 @@ spring:
application: application:
name: ai-rag-knowledge name: ai-rag-knowledge
profiles: profiles:
active: dev active: prod

View File

@ -4,4 +4,8 @@ TRUNCATE TABLE vector_store RESTART IDENTITY CASCADE; #清空向量表
SELECT metadata->>'path', COUNT(*) #查询知识库中包含哪些文件 SELECT metadata->>'path', COUNT(*) #查询知识库中包含哪些文件
FROM vector_store FROM vector_store
WHERE metadata->>'knowledge' = 'test-08' WHERE metadata->>'knowledge' = 'test-08'
GROUP BY metadata->>'path'; GROUP BY metadata->>'path';
psql -U postgres -c "\l" #查看有哪些库
psql -U postgres -d ai-rag-knowledge -c "\dt ollama.*" #查看这个库有哪些表

View File

@ -13,8 +13,8 @@ services:
- ./nginx/conf/nginx.conf:/etc/nginx/nginx.conf:ro - ./nginx/conf/nginx.conf:/etc/nginx/nginx.conf:ro
privileged: true privileged: true
networks: networks:
- my-network - ai-rag-knowledge-network
# ai-rag-knowledge
ai-rag-knowledge-app: ai-rag-knowledge-app:
build: build:
context: ../../.. # 从 docs/tag/v1.0 回到项目根 context: ../../.. # 从 docs/tag/v1.0 回到项目根
@ -32,8 +32,78 @@ services:
max-size: "10m" max-size: "10m"
max-file: "3" max-file: "3"
networks: networks:
- my-network - ai-rag-knowledge-network
ollama:
image: registry.cn-hangzhou.aliyuncs.com/xfg-studio/ollama:0.5.10
volumes:
- ./ollama:/root/.ollama
container_name: ollama
restart: unless-stopped
ports:
- "11434:11434"
networks:
- ai-rag-knowledge-network
redis:
image: registry.cn-hangzhou.aliyuncs.com/xfg-studio/redis:6.2
container_name: rag-redis
restart: always
hostname: redis
privileged: true
ports:
- 26379:6379
volumes:
- ./redis/redis.conf:/usr/local/etc/redis/redis.conf
command: redis-server /usr/local/etc/redis/redis.conf
networks:
- ai-rag-knowledge-network
healthcheck:
test: [ "CMD", "redis-cli", "ping" ]
interval: 10s
timeout: 5s
retries: 3
#向量库
vector_db:
image: registry.cn-hangzhou.aliyuncs.com/xfg-studio/pgvector:v0.5.0
container_name: vector_db
restart: always
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=ai-rag-knowledge
- PGPASSWORD=postgres
volumes:
- ./pgvector/sql/init.sql:/docker-entrypoint-initdb.d/init.sql
logging:
options:
max-size: 10m
max-file: "3"
ports:
- '15432:5432'
healthcheck:
test: "pg_isready -U postgres -d ai-rag-knowledge"
interval: 2s
timeout: 20s
retries: 10
networks:
- ai-rag-knowledge-network
# pg 管理工具
pgadmin:
image: registry.cn-hangzhou.aliyuncs.com/xfg-studio/pgadmin4:9.1.0
container_name: vector_db_admin
restart: always
ports:
- "5050:80"
environment:
PGADMIN_DEFAULT_EMAIL: admin@qq.com
PGADMIN_DEFAULT_PASSWORD: admin
depends_on:
- vector_db
networks:
- ai-rag-knowledge-network
networks: networks:
my-network: ai-rag-knowledge-network:
driver: bridge driver: bridge

View File

@ -75,8 +75,8 @@ services:
depends_on: depends_on:
- vector_db - vector_db
networks: networks:
- my-network - ai-rag-knowledge-network
-
networks: networks:
ai-rag-knowledge-network: ai-rag-knowledge-network:
driver: bridge driver: bridge

View File

@ -1,20 +0,0 @@
25-07-28.21:24:55.145 [main ] INFO Application - Starting Application v1.0 using Java 17.0.2 with PID 1 (/app.jar started by root in /)
25-07-28.21:24:55.150 [main ] INFO Application - The following 1 profile is active: "dev"
25-07-28.21:24:56.064 [main ] INFO RepositoryConfigurationDelegate - Multiple Spring Data modules found, entering strict repository configuration mode
25-07-28.21:24:56.067 [main ] INFO RepositoryConfigurationDelegate - Bootstrapping Spring Data Redis repositories in DEFAULT mode.
25-07-28.21:24:56.097 [main ] INFO RepositoryConfigurationDelegate - Finished Spring Data repository scanning in 14 ms. Found 0 Redis repository interfaces.
25-07-28.21:24:56.879 [main ] INFO TomcatWebServer - Tomcat initialized with port 8095 (http)
25-07-28.21:24:56.891 [main ] INFO Http11NioProtocol - Initializing ProtocolHandler ["http-nio-8095"]
25-07-28.21:24:56.893 [main ] INFO StandardService - Starting service [Tomcat]
25-07-28.21:24:56.894 [main ] INFO StandardEngine - Starting Servlet engine: [Apache Tomcat/10.1.19]
25-07-28.21:24:56.936 [main ] INFO [/] - Initializing Spring embedded WebApplicationContext
25-07-28.21:24:56.936 [main ] INFO ServletWebServerApplicationContext - Root WebApplicationContext: initialization completed in 1688 ms
25-07-28.21:24:57.400 [main ] INFO HikariDataSource - HikariCP - Starting...
25-07-28.21:24:57.627 [main ] INFO HikariPool - HikariCP - Added connection org.postgresql.jdbc.PgConnection@1c2dd89b
25-07-28.21:24:57.629 [main ] INFO HikariDataSource - HikariCP - Start completed.
25-07-28.21:25:01.124 [main ] INFO Version - Redisson 3.44.0
25-07-28.21:25:01.444 [redisson-netty-1-5] INFO ConnectionsHolder - 1 connections initialized for 192.168.10.218/192.168.10.218:26379
25-07-28.21:25:01.491 [redisson-netty-1-13] INFO ConnectionsHolder - 5 connections initialized for 192.168.10.218/192.168.10.218:26379
25-07-28.21:25:02.123 [main ] INFO Http11NioProtocol - Starting ProtocolHandler ["http-nio-8095"]
25-07-28.21:25:02.135 [main ] INFO TomcatWebServer - Tomcat started on port 8095 (http) with context path ''
25-07-28.21:25:02.146 [main ] INFO Application - Started Application in 7.872 seconds (process running for 8.608)

File diff suppressed because it is too large Load Diff

View File

@ -1,50 +0,0 @@
25-07-30.14:27:56.598 [main ] INFO Application - Starting Application v1.0 using Java 17.0.2 with PID 1 (/app.jar started by root in /)
25-07-30.14:27:56.605 [main ] INFO Application - The following 1 profile is active: "dev"
25-07-30.14:27:58.502 [main ] INFO RepositoryConfigurationDelegate - Multiple Spring Data modules found, entering strict repository configuration mode
25-07-30.14:27:58.511 [main ] INFO RepositoryConfigurationDelegate - Bootstrapping Spring Data Redis repositories in DEFAULT mode.
25-07-30.14:27:58.590 [main ] INFO RepositoryConfigurationDelegate - Finished Spring Data repository scanning in 35 ms. Found 0 Redis repository interfaces.
25-07-30.14:28:00.081 [main ] INFO TomcatWebServer - Tomcat initialized with port 8095 (http)
25-07-30.14:28:00.107 [main ] INFO Http11NioProtocol - Initializing ProtocolHandler ["http-nio-8095"]
25-07-30.14:28:00.110 [main ] INFO StandardService - Starting service [Tomcat]
25-07-30.14:28:00.110 [main ] INFO StandardEngine - Starting Servlet engine: [Apache Tomcat/10.1.19]
25-07-30.14:28:00.215 [main ] INFO [/] - Initializing Spring embedded WebApplicationContext
25-07-30.14:28:00.216 [main ] INFO ServletWebServerApplicationContext - Root WebApplicationContext: initialization completed in 3443 ms
25-07-30.14:28:01.314 [main ] INFO PgVectorStore - Using the vector table name: vector_store. Is empty: false
25-07-30.14:28:01.324 [main ] INFO PgVectorStore - Initializing PGVectorStore schema for table: vector_store in schema: public
25-07-30.14:28:01.324 [main ] INFO PgVectorStore - vectorTableValidationsEnabled false
25-07-30.14:28:02.253 [main ] INFO Version - Redisson 3.44.0
25-07-30.14:28:02.845 [redisson-netty-1-4] INFO ConnectionsHolder - 1 connections initialized for 192.168.10.218/192.168.10.218:26379
25-07-30.14:28:02.916 [redisson-netty-1-13] INFO ConnectionsHolder - 5 connections initialized for 192.168.10.218/192.168.10.218:26379
25-07-30.14:28:04.160 [main ] INFO Http11NioProtocol - Starting ProtocolHandler ["http-nio-8095"]
25-07-30.14:28:04.178 [main ] INFO TomcatWebServer - Tomcat started on port 8095 (http) with context path ''
25-07-30.14:28:04.226 [main ] INFO Application - Started Application in 8.958 seconds (process running for 10.028)
25-07-30.14:32:35.897 [http-nio-8095-exec-1] INFO [/] - Initializing Spring DispatcherServlet 'dispatcherServlet'
25-07-30.14:32:35.898 [http-nio-8095-exec-1] INFO DispatcherServlet - Initializing Servlet 'dispatcherServlet'
25-07-30.14:32:35.899 [http-nio-8095-exec-1] INFO DispatcherServlet - Completed initialization in 1 ms
25-07-30.14:32:38.801 [http-nio-8095-exec-5] INFO RAGController - 查询 RAG 标签列表数量5内容[test-01, test-02, test-03, my-repo-2025-07-29, study]
25-07-30.14:32:40.302 [http-nio-8095-exec-9] INFO RAGController - 查询 RAG 标签列表数量5内容[test-01, test-02, test-03, my-repo-2025-07-29, study]
25-07-30.14:32:44.850 [http-nio-8095-exec-10] INFO RAGController - 查询 RAG 标签列表数量5内容[test-01, test-02, test-03, my-repo-2025-07-29, study]
25-07-30.14:32:44.877 [http-nio-8095-exec-1] INFO RAGController - 查询 RAG 标签列表数量5内容[test-01, test-02, test-03, my-repo-2025-07-29, study]
25-07-30.14:33:41.992 [http-nio-8095-exec-5] INFO RAGController - 查询 RAG 标签列表数量5内容[test-01, test-02, test-03, my-repo-2025-07-29, study]
25-07-30.14:42:24.784 [http-nio-8095-exec-9] INFO RAGController - 查询 RAG 标签列表数量5内容[test-01, test-02, test-03, my-repo-2025-07-29, study]
25-07-30.14:42:24.817 [http-nio-8095-exec-10] INFO RAGController - 查询 RAG 标签列表数量5内容[test-01, test-02, test-03, my-repo-2025-07-29, study]
25-07-30.14:43:03.277 [http-nio-8095-exec-1] INFO RAGController - 查询 RAG 标签列表数量5内容[test-01, test-02, test-03, my-repo-2025-07-29, study]
25-07-30.14:43:03.301 [http-nio-8095-exec-2] INFO RAGController - 查询 RAG 标签列表数量5内容[test-01, test-02, test-03, my-repo-2025-07-29, study]
25-07-30.14:43:26.239 [http-nio-8095-exec-4] INFO RAGController - 查询 RAG 标签列表数量5内容[test-01, test-02, test-03, my-repo-2025-07-29, study]
25-07-30.14:43:26.262 [http-nio-8095-exec-3] INFO RAGController - 查询 RAG 标签列表数量5内容[test-01, test-02, test-03, my-repo-2025-07-29, study]
25-07-30.14:44:31.719 [http-nio-8095-exec-5] INFO RAGController - 查询 RAG 标签列表数量5内容[test-01, test-02, test-03, my-repo-2025-07-29, study]
25-07-30.14:44:31.745 [http-nio-8095-exec-8] INFO RAGController - 查询 RAG 标签列表数量5内容[test-01, test-02, test-03, my-repo-2025-07-29, study]
25-07-30.15:20:59.463 [http-nio-8095-exec-6] INFO RAGController - 查询 RAG 标签列表数量5内容[test-01, test-02, test-03, my-repo-2025-07-29, study]
25-07-30.15:20:59.497 [http-nio-8095-exec-7] INFO RAGController - 查询 RAG 标签列表数量5内容[test-01, test-02, test-03, my-repo-2025-07-29, study]
25-07-30.15:21:00.219 [http-nio-8095-exec-9] INFO RAGController - 查询 RAG 标签列表数量5内容[test-01, test-02, test-03, my-repo-2025-07-29, study]
25-07-30.15:21:00.248 [http-nio-8095-exec-10] INFO RAGController - 查询 RAG 标签列表数量5内容[test-01, test-02, test-03, my-repo-2025-07-29, study]
25-07-30.15:21:00.740 [http-nio-8095-exec-1] INFO RAGController - 查询 RAG 标签列表数量5内容[test-01, test-02, test-03, my-repo-2025-07-29, study]
25-07-30.15:21:00.764 [http-nio-8095-exec-2] INFO RAGController - 查询 RAG 标签列表数量5内容[test-01, test-02, test-03, my-repo-2025-07-29, study]
25-07-30.17:34:25.552 [http-nio-8095-exec-4] INFO RAGController - 查询 RAG 标签列表数量5内容[test-01, test-02, test-03, my-repo-2025-07-29, study]
25-07-30.17:34:25.601 [http-nio-8095-exec-3] INFO RAGController - 查询 RAG 标签列表数量5内容[test-01, test-02, test-03, my-repo-2025-07-29, study]
25-07-30.17:34:26.437 [http-nio-8095-exec-5] INFO RAGController - 查询 RAG 标签列表数量5内容[test-01, test-02, test-03, my-repo-2025-07-29, study]
25-07-30.17:34:26.469 [http-nio-8095-exec-8] INFO RAGController - 查询 RAG 标签列表数量5内容[test-01, test-02, test-03, my-repo-2025-07-29, study]
25-07-30.17:48:19.204 [http-nio-8095-exec-6] INFO RAGController - 查询 RAG 标签列表数量5内容[test-01, test-02, test-03, my-repo-2025-07-29, study]
25-07-30.17:48:19.233 [http-nio-8095-exec-7] INFO RAGController - 查询 RAG 标签列表数量5内容[test-01, test-02, test-03, my-repo-2025-07-29, study]
25-07-30.18:59:28.910 [http-nio-8095-exec-10] INFO RAGController - 查询 RAG 标签列表数量5内容[test-01, test-02, test-03, my-repo-2025-07-29, study]
25-07-30.21:07:54.809 [http-nio-8095-exec-5] INFO RAGController - 查询 RAG 标签列表数量5内容[test-01, test-02, test-03, my-repo-2025-07-29, study]

File diff suppressed because it is too large Load Diff

View File

@ -1,47 +0,0 @@
25-07-31.13:30:53.049 [main ] INFO Application - Starting Application v1.0 using Java 17.0.2 with PID 1 (/app.jar started by root in /)
25-07-31.13:30:53.060 [main ] INFO Application - The following 1 profile is active: "dev"
25-07-31.13:30:55.410 [main ] INFO RepositoryConfigurationDelegate - Multiple Spring Data modules found, entering strict repository configuration mode
25-07-31.13:30:55.418 [main ] INFO RepositoryConfigurationDelegate - Bootstrapping Spring Data Redis repositories in DEFAULT mode.
25-07-31.13:30:55.510 [main ] INFO RepositoryConfigurationDelegate - Finished Spring Data repository scanning in 40 ms. Found 0 Redis repository interfaces.
25-07-31.13:30:57.280 [main ] INFO TomcatWebServer - Tomcat initialized with port 8095 (http)
25-07-31.13:30:57.306 [main ] INFO Http11NioProtocol - Initializing ProtocolHandler ["http-nio-8095"]
25-07-31.13:30:57.312 [main ] INFO StandardService - Starting service [Tomcat]
25-07-31.13:30:57.312 [main ] INFO StandardEngine - Starting Servlet engine: [Apache Tomcat/10.1.19]
25-07-31.13:30:57.402 [main ] INFO [/] - Initializing Spring embedded WebApplicationContext
25-07-31.13:30:57.403 [main ] INFO ServletWebServerApplicationContext - Root WebApplicationContext: initialization completed in 4090 ms
25-07-31.13:30:58.549 [main ] INFO PgVectorStore - Using the vector table name: vector_store. Is empty: false
25-07-31.13:30:58.558 [main ] INFO PgVectorStore - Initializing PGVectorStore schema for table: vector_store in schema: public
25-07-31.13:30:58.559 [main ] INFO PgVectorStore - vectorTableValidationsEnabled false
25-07-31.13:30:59.682 [main ] INFO Version - Redisson 3.44.0
25-07-31.13:31:00.305 [redisson-netty-1-4] INFO ConnectionsHolder - 1 connections initialized for 192.168.10.218/192.168.10.218:26379
25-07-31.13:31:00.387 [redisson-netty-1-13] INFO ConnectionsHolder - 5 connections initialized for 192.168.10.218/192.168.10.218:26379
25-07-31.13:31:01.927 [main ] INFO Http11NioProtocol - Starting ProtocolHandler ["http-nio-8095"]
25-07-31.13:31:01.947 [main ] INFO TomcatWebServer - Tomcat started on port 8095 (http) with context path ''
25-07-31.13:31:01.989 [main ] INFO Application - Started Application in 10.658 seconds (process running for 11.933)
25-07-31.13:39:57.609 [main ] INFO Application - Starting Application v1.0 using Java 17.0.2 with PID 1 (/app.jar started by root in /)
25-07-31.13:39:57.614 [main ] INFO Application - The following 1 profile is active: "dev"
25-07-31.13:39:58.808 [main ] INFO RepositoryConfigurationDelegate - Multiple Spring Data modules found, entering strict repository configuration mode
25-07-31.13:39:58.821 [main ] INFO RepositoryConfigurationDelegate - Bootstrapping Spring Data Redis repositories in DEFAULT mode.
25-07-31.13:39:58.865 [main ] INFO RepositoryConfigurationDelegate - Finished Spring Data repository scanning in 20 ms. Found 0 Redis repository interfaces.
25-07-31.13:39:59.719 [main ] INFO TomcatWebServer - Tomcat initialized with port 8095 (http)
25-07-31.13:39:59.734 [main ] INFO Http11NioProtocol - Initializing ProtocolHandler ["http-nio-8095"]
25-07-31.13:39:59.736 [main ] INFO StandardService - Starting service [Tomcat]
25-07-31.13:39:59.737 [main ] INFO StandardEngine - Starting Servlet engine: [Apache Tomcat/10.1.19]
25-07-31.13:39:59.792 [main ] INFO [/] - Initializing Spring embedded WebApplicationContext
25-07-31.13:39:59.793 [main ] INFO ServletWebServerApplicationContext - Root WebApplicationContext: initialization completed in 2065 ms
25-07-31.13:40:00.413 [main ] INFO PgVectorStore - Using the vector table name: vector_store. Is empty: false
25-07-31.13:40:00.419 [main ] INFO PgVectorStore - Initializing PGVectorStore schema for table: vector_store in schema: public
25-07-31.13:40:00.420 [main ] INFO PgVectorStore - vectorTableValidationsEnabled false
25-07-31.13:40:01.016 [main ] INFO Version - Redisson 3.44.0
25-07-31.13:40:01.354 [redisson-netty-1-4] INFO ConnectionsHolder - 1 connections initialized for 192.168.10.218/192.168.10.218:26379
25-07-31.13:40:01.394 [redisson-netty-1-13] INFO ConnectionsHolder - 5 connections initialized for 192.168.10.218/192.168.10.218:26379
25-07-31.13:40:02.066 [main ] INFO Http11NioProtocol - Starting ProtocolHandler ["http-nio-8095"]
25-07-31.13:40:02.077 [main ] INFO TomcatWebServer - Tomcat started on port 8095 (http) with context path ''
25-07-31.13:40:02.100 [main ] INFO Application - Started Application in 5.249 seconds (process running for 6.188)
25-07-31.13:40:15.914 [http-nio-8095-exec-1] INFO [/] - Initializing Spring DispatcherServlet 'dispatcherServlet'
25-07-31.13:40:15.915 [http-nio-8095-exec-1] INFO DispatcherServlet - Initializing Servlet 'dispatcherServlet'
25-07-31.13:40:15.916 [http-nio-8095-exec-1] INFO DispatcherServlet - Completed initialization in 1 ms
25-07-31.13:40:15.968 [http-nio-8095-exec-2] INFO RAGController - 查询 RAG 标签列表数量5内容[test-01, test-02, test-03, my-repo-2025-07-29, study]
25-07-31.13:40:18.236 [http-nio-8095-exec-6] INFO RAGController - 查询 RAG 标签列表数量5内容[test-01, test-02, test-03, my-repo-2025-07-29, study]
25-07-31.13:40:21.021 [http-nio-8095-exec-7] INFO RAGController - 查询 RAG 标签列表数量5内容[test-01, test-02, test-03, my-repo-2025-07-29, study]
25-07-31.13:40:21.136 [http-nio-8095-exec-8] INFO RAGController - 查询 RAG 标签列表数量5内容[test-01, test-02, test-03, my-repo-2025-07-29, study]

View File

@ -2,9 +2,9 @@ CREATE EXTENSION IF NOT EXISTS vector;
CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
-- Ollamanomic-embed-text768 维 -- Ollamanomic-embed-text768 维
CREATE SCHEMA IF NOT EXISTS ollama; CREATE SCHEMA IF NOT EXISTS public;
DROP TABLE IF EXISTS ollama.vector_store; DROP TABLE IF EXISTS public.vector_store;
CREATE TABLE ollama.vector_store ( CREATE TABLE public.vector_store (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(), id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
content TEXT NOT NULL, content TEXT NOT NULL,
metadata JSONB, metadata JSONB,