重构代码,实现相对导入
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Failing after 5m26s

This commit is contained in:
2026-04-21 10:26:37 +08:00
parent 37e021e302
commit 726236eaff
68 changed files with 119 additions and 3990 deletions

View File

@@ -1,15 +0,0 @@
FROM python:3.11-slim
WORKDIR /app
COPY requirement.txt .
RUN pip install --no-cache-dir -r requirement.txt
COPY frontend/ ./frontend/
COPY app/ ./app/
ENV PYTHONPATH=/app
EXPOSE 8501
CMD ["streamlit", "run", "frontend/frontend_main.py", "--server.port", "8501", "--server.address", "0.0.0.0", "--server.baseUrlPath", "/ai"]

View File

@@ -10,6 +10,7 @@ ENV PYTHONPATH=/app
# llama.cpp 服务配置(本地部署标准端口)
ENV VLLM_BASE_URL=http://host.docker.internal:18000/v1
ENV LLAMACPP_EMBEDDING_URL=http://host.docker.internal:18001/v1
ENV LLAMACPP_RERENT_URL=http://host.docker.internal:18002/v1
# Mem0 记忆层配置
ENV QDRANT_COLLECTION_NAME=mem0_user_memories
@@ -40,30 +41,21 @@ RUN pip install --no-cache-dir /tmp/models/*.whl && \
RUN pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
# 复制 requirement 并安装(增加超时时间)
COPY requirement.txt .
RUN pip install --no-cache-dir --default-timeout=300 -r requirement.txt
COPY backend/requirements.txt .
RUN pip install --no-cache-dir --default-timeout=300 -r requirements.txt
# =============================================================================
# 预下载 spaCy 语言模型(避免容器启动时重复下载)
# 复制项目代码
# =============================================================================
RUN pip install --no-cache-dir spacy && \
python -m spacy download en_core_web_sm && \
python -m spacy download zh_core_web_sm
# =============================================================================
# 复制项目代码 (只复制必需的文件夹,避免依赖被忽略的目录)
# =============================================================================
COPY rag_core/ ./rag_core/
COPY app/ ./app/
COPY frontend/ ./frontend/
COPY scripts/ ./scripts/
COPY backend/ ./
# =============================================================================
# 暴露端口
# =============================================================================
EXPOSE 8083
EXPOSE 8079
# =============================================================================
# 启动命令
# =============================================================================
CMD ["python", "app/backend.py"]
CMD ["python", "app/backend.py"]

View File

@@ -5,7 +5,7 @@ services:
backend:
build:
context: .. # 构建上下文为项目根目录
dockerfile: docker/Dockerfile.backend
dockerfile: docker/backend/Dockerfile
container_name: ai-backend
environment:
# ⭐ 敏感密钥:通过 .env 注入
@@ -26,7 +26,7 @@ services:
- QDRANT_URL=http://115.190.121.151:6333
# 前端通信地址Docker 内部网络)
- API_URL=http://backend:8083/chat
- API_URL=http://backend:8079/chat
volumes:
- ../data/user_docs:/app/data/user_docs # 挂载文档目录
- ../logs:/app/logs
@@ -35,16 +35,16 @@ services:
# ⭐ 移除对 postgres 和 qdrant 的依赖
restart: unless-stopped
ports:
- "8083:8083"
- "8079:8079"
frontend:
build:
context: ..
dockerfile: docker/Dockerfile.frontend
dockerfile: docker/frontend/Dockerfile
container_name: ai-frontend
environment:
# Docker 内部网络使用服务名 'backend' 解析后端服务
- API_URL=http://backend:8083/chat
- API_URL=http://backend:8079/chat
ports:
- "8501:8501"
networks:
@@ -56,8 +56,3 @@ services:
networks:
ai-network:
driver: bridge
# ⭐ PostgreSQL 和 Qdrant 已迁移到远程服务器,不再需要本地卷
# volumes:
# pg_data:
# qdrant_storage:

View File

@@ -0,0 +1,21 @@
FROM python:3.11-slim
WORKDIR /app
ENV PYTHONPATH=/app
# 设置 pip 国内镜像源
RUN pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
# 复制前端依赖并安装
COPY frontend/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# 复制前端代码
COPY frontend/src/ ./frontend/
# 暴露端口
EXPOSE 8501
# 启动命令
CMD ["streamlit", "run", "frontend/frontend_main.py", "--server.port", "8501", "--server.address", "0.0.0.0", "--server.baseUrlPath", "/ai"]