FROM python:3.11-slim WORKDIR /app # ============================================================================= # 非敏感环境变量(固化在镜像中,无需通过 .env 配置) # ============================================================================= 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 # Mem0 记忆层配置 ENV QDRANT_COLLECTION_NAME=mem0_user_memories # 应用行为配置(可通过 .env 覆盖) ENV MEMORY_SUMMARIZE_INTERVAL=10 ENV ENABLE_GRAPH_TRACE=false # unstructured 库 spaCy 模型配置 ENV UNSTRUCTURED_LANGUAGE=eng ENV SPACY_MODEL=en_core_web_sm # 日志配置 ENV LOG_LEVEL=WARNING ENV DEBUG=false # ============================================================================= # 安装依赖 # ============================================================================= # 复制本地模型文件到镜像 COPY docker/models/*.whl /tmp/models/ # 安装 RUN pip install --no-cache-dir /tmp/models/*.whl && \ rm -rf /tmp/models # 设置 pip 国内镜像源 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 # ============================================================================= # 预下载 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/ # ============================================================================= # 暴露端口 # ============================================================================= EXPOSE 8083 # ============================================================================= # 启动命令 # ============================================================================= CMD ["python", "app/backend.py"]