Files
ailine/docker/backend/Dockerfile
root a869d884b7
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Failing after 7m1s
docs: 更新文档路径引用,移除硬编码密钥,修复 Docker 配置
2026-04-22 00:43:06 +08:00

90 lines
3.6 KiB
Docker
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

FROM python:3.11-slim
WORKDIR /app
# =============================================================================
# 非敏感环境变量(固化在镜像中,可通过 .env 覆盖)
# =============================================================================
ENV PYTHONPATH=/app
# =============================================================================
# llama.cpp 服务配置Docker 部署标准端口映射)
# =============================================================================
# 主 LLM 服务 - Docker host 端口 18000
ENV VLLM_BASE_URL=http://host.docker.internal:18000/v1
# Embedding 服务 - Docker host 端口 18001
ENV LLAMACPP_EMBEDDING_URL=http://host.docker.internal:18001/v1
# Reranker 服务 - Docker host 端口 18002
ENV LLAMACPP_RERANKER_URL=http://host.docker.internal:18002/v1
# =============================================================================
# 数据库 & 向量库配置(非敏感部分)
# =============================================================================
# PostgreSQL敏感信息通过 .env 注入)
ENV DB_HOST=115.190.121.151
ENV DB_PORT=5432
ENV DB_USER=postgres
ENV DB_NAME=langgraph_db
# Qdrant敏感信息通过 .env 注入)
ENV QDRANT_URL=http://115.190.121.151:6333
ENV QDRANT_COLLECTION_NAME=mem0_user_memories
# =============================================================================
# RAG 索引构建配置(非敏感)
# =============================================================================
ENV RAG_COLLECTION_NAME=rag_documents
ENV RAG_CHUNK_SIZE=500
ENV RAG_CHUNK_OVERLAP=50
ENV RAG_PARENT_CHUNK_SIZE=1000
ENV RAG_CHILD_CHUNK_SIZE=200
ENV RAG_PARENT_CHUNK_OVERLAP=100
ENV RAG_CHILD_CHUNK_OVERLAP=20
ENV RAG_STRATEGY=parent-child
ENV RAG_STORAGE_TYPE=postgres
# =============================================================================
# 应用行为配置
# =============================================================================
ENV MEMORY_SUMMARIZE_INTERVAL=10
ENV ENABLE_GRAPH_TRACE=false
# =============================================================================
# 日志配置(生产环境默认值)
# =============================================================================
ENV LOG_LEVEL=WARNING
ENV DEBUG=false
# =============================================================================
# 安装依赖
# =============================================================================
# 复制本地模型文件到镜像(如果有)
# 注意docker/models/ 目录需要在构建上下文中存在
COPY docker/models/ /tmp/models/
# 安装本地模型 wheel如果有 .whl 文件)
RUN find /tmp/models -name "*.whl" -type f 2>/dev/null | head -1 | xargs -r pip install --no-cache-dir && \
rm -rf /tmp/models
# 设置 pip 国内镜像源
RUN pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
# 复制 requirement 并安装(增加超时时间)
COPY backend/requirements.txt .
RUN pip install --no-cache-dir --default-timeout=300 -r requirements.txt
# =============================================================================
# 复制项目代码
# =============================================================================
COPY backend/ ./
# =============================================================================
# 暴露端口
# =============================================================================
EXPOSE 8079
# =============================================================================
# 启动命令
# =============================================================================
CMD ["python", "-m", "app.backend"]