Files
ailine/docker/backend/Dockerfile
root 13e1d03741
All checks were successful
构建并部署 AI Agent 服务 / deploy (push) Successful in 5m48s
修复 Dockerfile 启动命令为 backend.app.backend
2026-05-06 11:29:05 +08:00

104 lines
4.3 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 BACKEND_PORT=8079
ENV MEMORY_SUMMARIZE_INTERVAL=10
ENV ENABLE_GRAPH_TRACE=false
# =============================================================================
# 稀疏模型配置
# =============================================================================
ENV SPARSE_MODEL_PATH=/app/models/sparse
ENV SPARSE_MODEL_NAME=Qdrant/bm25
ENV FASTEMBED_CACHE_PATH=/app/fastembed_cache
# =============================================================================
# 日志配置(生产环境默认值)
# =============================================================================
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/*.whl # 只删除 wheel保留 fastembed_cache
# 设置 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
# =============================================================================
# 复制预下载的BM25模型缓存FastEmbed
# =============================================================================
# 注意:模型在 docker/models/fastembed_cache 里
COPY docker/models/fastembed_cache /app/fastembed_cache
# =============================================================================
# 复制项目代码(保持 backend 目录结构,适配绝对导入 from backend.app.xxx
# =============================================================================
COPY backend /app/backend
# =============================================================================
# 暴露端口
# =============================================================================
EXPOSE 8079
# =============================================================================
# 启动命令
# =============================================================================
CMD ["python", "-m", "backend.app.backend"]