Преглед на файлове

feat(部署配置): 优化前端构建流程并调整nginx路由配置

重构前端Dockerfile构建流程,分离管理端和聊天端构建产物
调整nginx配置以支持聊天应用的路由和API代理
更新后端依赖安装顺序,确保torch优先安装
DengPeng преди 2 седмици
родител
ревизия
065de20228
променени са 3 файла, в които са добавени 15 реда и са изтрити 3 реда
  1. 2 2
      Dockerfile.backend
  2. 8 1
      Dockerfile.frontend
  3. 5 0
      ui/nginx.conf

+ 2 - 2
Dockerfile.backend

@@ -27,6 +27,8 @@ RUN pip install --no-cache-dir --upgrade pip setuptools wheel
 
 COPY pyproject.toml ./
 
+RUN pip install --no-cache-dir --break-system-packages torch==2.8.0 --index-url https://pypi.tuna.tsinghua.edu.cn/simple
+
 RUN pip install --no-cache-dir --break-system-packages \
     django==5.2.13 \
     drf-spectacular==0.28.0 \
@@ -84,8 +86,6 @@ RUN pip install --no-cache-dir --break-system-packages \
     jsonpath-ng==1.8.0 \
     sentence-transformers==5.0.0
 
-RUN pip install --no-cache-dir --break-system-packages torch==2.8.0 --index-url https://pypi.tuna.tsinghua.edu.cn/simple
-
 COPY apps/ ./apps/
 COPY main.py ./
 

+ 8 - 1
Dockerfile.frontend

@@ -11,7 +11,14 @@ COPY ui/ ./
 
 ENV NODE_OPTIONS="--max-old-space-size=4096"
 
-RUN npm run build-only
+RUN npm run build-only && \
+    mv dist dist_admin && \
+    npm run build-only-chat && \
+    mv dist dist_chat && \
+    mv dist_admin/* dist_chat/ && \
+    mv dist_chat/chat dist_admin/ && \
+    rm -rf dist_chat && \
+    mv dist_admin dist
 
 FROM nginx:alpine
 

+ 5 - 0
ui/nginx.conf

@@ -25,6 +25,11 @@ server {
     }
 
     location /chat {
+        alias /usr/share/nginx/html/chat;
+        try_files $uri $uri/ /chat/index.html;
+    }
+
+    location /chat/api {
         proxy_pass http://maxkb-web:8080;
         proxy_set_header Host $host;
         proxy_set_header X-Real-IP $remote_addr;