FROM python:3.11-slim WORKDIR /app # 安装系统依赖 RUN apt-get update && apt-get install -y \ curl \ && rm -rf /var/lib/apt/lists/* # 安装 Python 依赖 RUN pip install --no-cache-dir \ fastapi==0.109.0 \ uvicorn[standard]==0.27.0 \ pydantic==2.5.3 \ requests>=2.31.0 # 复制 common 模块(回调工具) COPY common/agent_callback_utils.py /app/common/ RUN touch /app/common/__init__.py # 复制应用代码 COPY agents/echo_agent/echo_agent.py /app/ # 环境变量 ENV PYTHONUNBUFFERED=1 ENV SERVICE_HOST=0.0.0.0 ENV SERVICE_PORT=8000 # 回调配置 ENV AGENT_CALLBACK_URL=http://mcp-server:8002/api/v1/billing/agent-callback # 健康检查 HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \ CMD python3 -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health').read()" || exit 1 EXPOSE 8000 CMD ["python3", "-u", "echo_agent.py"]