41 lines
998 B
Docker
41 lines
998 B
Docker
|
|
# Python RAG API服务 Dockerfile
|
||
|
|
FROM python:3.10-slim
|
||
|
|
|
||
|
|
# 设置工作目录
|
||
|
|
WORKDIR /app
|
||
|
|
|
||
|
|
# 安装系统依赖
|
||
|
|
RUN apt-get update && apt-get install -y \
|
||
|
|
build-essential \
|
||
|
|
curl \
|
||
|
|
&& rm -rf /var/lib/apt/lists/*
|
||
|
|
|
||
|
|
# 复制依赖文件
|
||
|
|
COPY retriver/requirements.txt /app/requirements.txt
|
||
|
|
|
||
|
|
# 安装Python依赖
|
||
|
|
RUN pip install --no-cache-dir -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt && \
|
||
|
|
pip install --no-cache-dir -i https://pypi.tuna.tsinghua.edu.cn/simple \
|
||
|
|
fastapi \
|
||
|
|
uvicorn[standard] \
|
||
|
|
pyyaml
|
||
|
|
|
||
|
|
# 复制项目文件
|
||
|
|
COPY . /app
|
||
|
|
|
||
|
|
# 创建输出目录
|
||
|
|
RUN mkdir -p /app/api_outputs
|
||
|
|
|
||
|
|
# 设置环境变量
|
||
|
|
ENV PYTHONPATH=/app
|
||
|
|
ENV RAG_CONFIG_PATH=rag_config_production.yaml
|
||
|
|
|
||
|
|
# 暴露端口
|
||
|
|
EXPOSE 8000
|
||
|
|
|
||
|
|
# 健康检查
|
||
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
||
|
|
CMD curl -f http://localhost:8000/health || exit 1
|
||
|
|
|
||
|
|
# 启动服务
|
||
|
|
CMD ["uvicorn", "rag_api_server_production:app", "--host", "0.0.0.0", "--port", "8000"]
|