FROM python:3.11-slim

# 设置工作目录
WORKDIR /app

# 安装系统依赖
RUN apt-get update && apt-get install -y \
    curl \
    && rm -rf /var/lib/apt/lists/*

# 安装LiteLLM
RUN pip install --no-cache-dir \
    litellm[proxy]==1.17.0 \
    redis==5.0.1 \
    prometheus-client==0.19.0

# 复制配置文件
COPY config/ ./config/

# 创建logs目录
RUN mkdir -p logs

# 设置环境变量
ENV LITELLM_MASTER_KEY=sk-taiji-master-key
ENV LITELLM_CONFIG_PATH=/app/config/litellm.yaml

# 暴露端口
EXPOSE 4000

# 健康检查
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
  CMD curl -f http://localhost:4000/health || exit 1

# 启动LiteLLM代理
CMD ["litellm", "--config", "/app/config/litellm.yaml", "--port", "4000", "--host", "0.0.0.0"]

