diff --git a/bbit_ai/app/app.py b/bbit_ai/app/app.py index 6170594..ea13e53 100644 --- a/bbit_ai/app/app.py +++ b/bbit_ai/app/app.py @@ -6,6 +6,7 @@ from routers.Chat import chatRouter from routers.Datasource import reportDataRouter from routers.F8 import f8Router from routers.Knowledge import knowledgeRouter +from routers.Public import publicRouter from routers.RabbitMQ import rqRouter from routers.Report import reportRouter from routers.Service import serviceRouter @@ -45,4 +46,6 @@ for r in routers: app.include_router(f8Router, prefix="/f8", tags=["f8"]) +app.include_router(publicRouter, prefix="/api/public", tags=["api"]) + MyUtils.async_new_task(mq_pull_analysis) diff --git a/bbit_ai/app/routers/Public.py b/bbit_ai/app/routers/Public.py new file mode 100644 index 0000000..b0233fe --- /dev/null +++ b/bbit_ai/app/routers/Public.py @@ -0,0 +1,32 @@ +import base64 + +from fastapi import APIRouter + +from config.app import F8_SERVER_USER_ID +from models.BaseResponse import BaseResponse +from models.F8ImageRequestV2 import F8ImageRequestV2 +from service.vision import process_ticket_image +from utils import MyUtils + +publicRouter = APIRouter() + + +@publicRouter.post("/recognize-cocoon-metrics") +async def cocoonTicket(data: F8ImageRequestV2): + input_data = data.image + if "," in input_data: + input_data = input_data.split(",")[1] + try: + img_bytes = base64.b64decode(input_data) + json_data = await MyUtils.async_task( + process_ticket_image, + 2, + data.needBarcode, + img_bytes, + f"{data.title}.jpg", + data.title, + F8_SERVER_USER_ID, + ) + return BaseResponse(data=json_data) + except Exception as e: + return BaseResponse(status=False, message=f"解析失败: {str(e)}", data=None) diff --git a/readme.md b/readme.md index 2c9efc2..b32e3e2 100644 --- a/readme.md +++ b/readme.md @@ -2,11 +2,13 @@ ## 一、技术栈 -- ### 部署 +- ### 运维 - **Docker**:项目部署 - **Nginx**:前端项目部署 - **Kong**: 网关 + - **Prometheus**:服务监控 + - **Grafana**:数据可视化 - ### 前端 @@ -154,7 +156,75 @@ docker compose up -d docker image prune -f ``` -## 四、其他 +## 四、配置 + +- 安装顺序 + + 1. 安装docker + 2. 运行基本环境infra-compose.yaml + 3. 安装Harbor + 4. 推送镜像 + 5. 运行前后端程序docker-compose.yaml + +- Harbor + + 1. 添加用户 + + 2. 添加仓库 + + 3. 添加仓库用户使用权限 + + 4. (2x客户端)登录 + ``` + docker login http://s1.ronsunny.cn:13011 + ``` + +- Prometheus + + 1. 设置docker metrics配置文件 + ``` + { + "registry-mirrors": [ + "https://docker.m.daocloud.io", + "https://mirror.baidubce.com", + "https://docker.nju.edu.cn" + ], + "metrics-addr": "10.10.10.9:9323", + "experimental": true, + "insecure-registries": ["s1.ronsunny.cn:13011"] + } + ``` + + 2. 重启docker + ``` + sudo systemctl restart docker + ``` + +- RabbitMQ + + 1. 添加用户 + 2. 添加Vhost + +- [Grafana][https://grafana.com/grafana/dashboards/] + + 1. 创建Prometheus数据源 + + 2. 增加配置 + + | 项目 | 代码 | 描述 | + | ----------- | ----- | ---- | + | MinIO | 13502 | | + | Docker | 9621 | | + | PostgreSQL | 9628 | | + | 主机 | 1860 | | + | RabbitMQ | 10991 | | + | Redis | 11835 | | + | Prometheus | 19268 | | + | 主机 中文版 | 8919 | | + + + +## 五、其他 ### 旧部署 diff --git a/server/docker/docker-compose.yaml b/server/docker/docker-compose.yaml index eede265..c871ac5 100644 --- a/server/docker/docker-compose.yaml +++ b/server/docker/docker-compose.yaml @@ -1,11 +1,3 @@ - -x-kong-config: - &kong-env - KONG_DATABASE: postgres - KONG_PG_HOST: postgres - KONG_PG_DATABASE: kong - KONG_PG_USER: postgres - KONG_PG_PASSWORD: 123456 services: # ---------- Vue 前端 ---------- vue: diff --git a/server/docker/infra-compose.yaml b/server/docker/infra-compose.yaml index 30afa80..e1ea640 100644 --- a/server/docker/infra-compose.yaml +++ b/server/docker/infra-compose.yaml @@ -7,6 +7,7 @@ x-kong-config: KONG_PG_USER: postgres KONG_PG_PASSWORD: 123456 services: + # ---------- PostgreSQL ---------- postgres: container_name: ce_postgres @@ -15,6 +16,7 @@ services: POSTGRES_DB: ktor # 实际上这里已经没用了,因为卷已经创建了,现在在用ktor2、kong两个数据库 POSTGRES_USER: postgres POSTGRES_PASSWORD: 123456 + POSTGRES_HOST_AUTH_METHOD: trust ports: - "5432:5432" volumes: @@ -27,6 +29,11 @@ services: redis: container_name: ce_redis image: redis:7.2.3-alpine + command: [ + "redis-server", + "--save", "60", "100", + "--appendonly", "yes", + ] volumes: - redis_data:/data ports: @@ -50,13 +57,13 @@ services: - minio_data:/data networks: - ce_network - restart: unless-stopped command: server /data --console-address ":9001" healthcheck: test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"] - interval: 10s - timeout: 5s - retries: 5 + interval: 30s + timeout: 20s + retries: 3 + restart: unless-stopped # ---------- ETCD ---------- etcd: @@ -69,15 +76,15 @@ services: - ETCD_SNAPSHOT_COUNT=50000 networks: - ce_network - restart: unless-stopped volumes: - etcd_data:/data/etcd command: etcd -advertise-client-urls=http://etcd:2379 -listen-client-urls http://0.0.0.0:2379 --data-dir /data/etcd healthcheck: test: ["CMD", "etcdctl", "endpoint", "health"] - interval: 10s - timeout: 5s - retries: 5 + interval: 30s + timeout: 20s + retries: 3 + restart: unless-stopped # ---------- Milvus ---------- milvus: @@ -86,7 +93,6 @@ services: command: ["milvus", "run", "standalone"] security_opt: - seccomp:unconfined - restart: unless-stopped environment: ETCD_ENDPOINTS: etcd:2379 MINIO_ADDRESS: minio:9000 @@ -107,6 +113,7 @@ services: depends_on: - etcd - minio + restart: unless-stopped # ---------- Attu ---------- attu: @@ -118,9 +125,9 @@ services: - ce_network ports: - "3000:3000" # 浏览器访问端口 - restart: unless-stopped depends_on: - milvus + restart: unless-stopped # ---------- Kong 网关 ---------- kong-migrations: @@ -184,7 +191,6 @@ services: rabbitmq: image: rabbitmq:4.2-rc-management-alpine container_name: ce_rabbitmq - restart: always environment: RABBITMQ_DEFAULT_USER: admin RABBITMQ_DEFAULT_PASS: 123456 @@ -198,12 +204,12 @@ services: - rabbitmq_data:/var/lib/rabbitmq networks: - ce_network + restart: unless-stopped # ---------- prometheus ---------- prometheus: image: prom/prometheus:v3.7.0-rc.0 container_name: ce_prometheus - restart: always volumes: - ./config/prometheus:/etc/prometheus - prometheus_data:/prometheus @@ -219,12 +225,12 @@ services: - postgres-exporter - rabbitmq - redis-exporter + restart: unless-stopped # ---------- grafana ---------- grafana: image: grafana/grafana:12.3.0-18481575143-ubuntu container_name: ce_grafana - restart: always ports: - "0.0.0.0:3001:3000" environment: @@ -237,6 +243,8 @@ services: - prometheus networks: - ce_network + restart: unless-stopped + # ---------- Redis Exporter ---------- redis-exporter: image: oliver006/redis_exporter:v1.78.0-alpine @@ -247,9 +255,9 @@ services: # - "9121:9121" # 无需暴露内网端口 直接通过ce_redis_exporter访问即可 networks: - ce_network - restart: unless-stopped depends_on: - redis + restart: unless-stopped # ---------- PostgreSQL Exporter ---------- postgres-exporter: @@ -261,9 +269,9 @@ services: # - "9187:9187" # 无需暴露内网端口 直接通过ce_postgres_exporter访问即可 networks: - ce_network - restart: unless-stopped depends_on: - postgres + restart: unless-stopped # ---------- node_exporter ---------- node_exporter: @@ -273,9 +281,9 @@ services: - '--path.rootfs=/host' network_mode: host pid: host - restart: unless-stopped volumes: - '/:/host:ro,rslave' + restart: unless-stopped # ---------- 数据卷 ---------- volumes: @@ -296,6 +304,7 @@ volumes: rabbitmq_data: prometheus_config: prometheus_data: + # ---------- 网络 ---------- networks: ce_network: diff --git a/vue/apps/web-antd/src/preferences.ts b/vue/apps/web-antd/src/preferences.ts index ecc1071..659c1d3 100644 --- a/vue/apps/web-antd/src/preferences.ts +++ b/vue/apps/web-antd/src/preferences.ts @@ -9,7 +9,7 @@ export const overridesPreferences = defineOverridesPreferences({ // overrides app: { name: import.meta.env.VITE_APP_TITLE, - layout: 'sidebar-mixed-nav', + layout: 'header-sidebar-nav', defaultHomePath: '/workspace', // 默认首页路径 enablePreferences: false, // 是否启用偏好设置 loginExpiredMode: 'page', // 登录过期模式 不用弹窗登录 跳转到页面登录,防止一些界面不会再加载 @@ -21,6 +21,7 @@ export const overridesPreferences = defineOverridesPreferences({ breadcrumb: { hideOnlyOne: true, styleType: 'normal', + showHome: true, }, copyright: { enable: false, @@ -31,7 +32,7 @@ export const overridesPreferences = defineOverridesPreferences({ sidebar: { collapsed: false, fixedButton: true, - width: 170, + width: 190, }, transition: { name: 'fade-up', @@ -40,6 +41,7 @@ export const overridesPreferences = defineOverridesPreferences({ lockScreen: false, notification: false, languageToggle: false, + themeToggle: false, }, navigation: { accordion: false, diff --git a/vue/apps/web-antd/src/router/routes/modules/set.ts b/vue/apps/web-antd/src/router/routes/modules/set.ts index af3590f..a42698e 100644 --- a/vue/apps/web-antd/src/router/routes/modules/set.ts +++ b/vue/apps/web-antd/src/router/routes/modules/set.ts @@ -22,7 +22,7 @@ const routes: RouteRecordRaw[] = [ meta: { icon: 'mdi:monitor-dashboard', link: 'http://10.10.10.9:8002/', - title: 'Kong后台', + title: '网关', }, }, { @@ -32,7 +32,7 @@ const routes: RouteRecordRaw[] = [ meta: { icon: 'mdi:monitor-dashboard', link: 'http://10.10.10.9:9001', - title: 'MinIO后台', + title: '对象存储', }, }, { @@ -42,7 +42,7 @@ const routes: RouteRecordRaw[] = [ meta: { icon: 'mdi:monitor-dashboard', link: 'http://10.10.10.9:9091/webui', - title: 'Milvus后台', + title: '向量数据库', }, }, { @@ -52,7 +52,7 @@ const routes: RouteRecordRaw[] = [ meta: { icon: 'mdi:monitor-dashboard', link: 'http://10.10.10.9:3000/', - title: 'Milvus Attu后台', + title: '向量数据库Attu', }, }, { @@ -62,7 +62,7 @@ const routes: RouteRecordRaw[] = [ meta: { icon: 'mdi:monitor-dashboard', link: 'http://10.10.10.9:15672', - title: 'RabbitMQ后台', + title: '消息队列', }, }, { @@ -72,7 +72,7 @@ const routes: RouteRecordRaw[] = [ meta: { icon: 'mdi:monitor-dashboard', link: 'http://10.10.10.9:13011', - title: 'Harbor后台', + title: '容器管理', }, }, { @@ -82,7 +82,7 @@ const routes: RouteRecordRaw[] = [ meta: { icon: 'mdi:monitor-dashboard', link: 'http://10.10.10.9:9090', - title: 'Prometheus后台', + title: '日志监控', }, }, { @@ -92,7 +92,7 @@ const routes: RouteRecordRaw[] = [ meta: { icon: 'mdi:monitor-dashboard', link: 'http://10.10.10.9:3001', - title: 'Grafana后台', + title: '数据可视化', }, }, ], diff --git a/vue/docker-compose.yml b/vue/docker-compose.yml deleted file mode 100644 index 8438495..0000000 --- a/vue/docker-compose.yml +++ /dev/null @@ -1,90 +0,0 @@ -services: - vue: - container_name: ce_vue - image: ce-vue:latest - ports: - - "8090:8090" # 映射到宿主机的 8090 端口 - restart: always - networks: - - ce_network - - backend: - container_name: ce-pybackend - image: ce-pybackend:latest - ports: - - "13011:13011" - restart: unless-stopped - networks: - - ce_network - depends_on: - - vue - - postgres: - image: postgres:15-alpine - container_name: ce_postgres - environment: - POSTGRES_DB: ktor - POSTGRES_USER: postgres - POSTGRES_PASSWORD: 123456 - volumes: - - postgres_data:/var/lib/postgresql/data - ports: - - "5432:5432" - networks: - - ce_network - restart: unless-stopped - - redis: - image: redis:7.2.3-alpine - container_name: ce_redis - volumes: - - redis_data:/data - ports: - - "6379:6379" - networks: - - ce_network - restart: unless-stopped - - minio: - image: minio/minio:RELEASE.2025-03-12T18-04-18Z - container_name: ce_minio - environment: - MINIO_ACCESS_KEY: minioadmin - MINIO_SECRET_KEY: minioadmin - volumes: - - minio_data:/data - ports: - - "9000:9000" - - "9001:9001" - command: server /data --console-address ":9001" - networks: - - ce_network - restart: unless-stopped - -# ollama: -# image: ollama/ollama -# container_name: ce_ollama -# deploy: -# resources: -# reservations: -# devices:7 -# - capabilities: [gpu] # 启用 GPU 支持 -# volumes: -# - ollama_data:/root/.ollama # 持久化 ollama 数据 -# ports: -# - "11434:11434" # 暴露 ollama 的端口 -# networks: -# - ce_network -# restart: unless-stopped - -# 定义数据卷 -volumes: - postgres_data: - redis_data: - minio_data: - ollama_data: # 定义 ollama 的数据卷 - -# 定义网络 -networks: - ce_network: - driver: bridge diff --git a/vue/scripts/deploy/nginx.conf b/vue/scripts/deploy/nginx.conf index ecb9061..e6ba732 100644 --- a/vue/scripts/deploy/nginx.conf +++ b/vue/scripts/deploy/nginx.conf @@ -1,51 +1,13 @@ - -#user nobody; worker_processes 1; -#error_log logs/error.log; -#error_log logs/error.log notice; -#error_log logs/error.log info; - -#pid logs/nginx.pid; - - events { worker_connections 1024; } - http { include mime.types; default_type application/octet-stream; - - types { - application/javascript js mjs; - text/css css; - text/html html; - } - sendfile on; - # tcp_nopush on; - - #keepalive_timeout 0; - # keepalive_timeout 65; - - # gzip on; - # gzip_buffers 32 16k; - # gzip_comp_level 6; - # gzip_min_length 1k; - # gzip_static on; - # gzip_types text/plain - # text/css - # application/javascript - # application/json - # application/x-javascript - # text/xml - # application/xml - # application/xml+rss - # text/javascript; #设置压缩的文件类型 - # gzip_vary on; - server { listen 8091; server_name localhost;