# 选项1：阿里云镜像
FROM python:3.10.15-slim  

# 设置工作目录
WORKDIR /app

# 安装系统依赖
RUN apt-get update && apt-get install -y \
    build-essential \
    pkg-config \
    libssl-dev \
    libxrender1 \
    libxext6 \
    libsm6 \
    libice6 \
    libfreetype6-dev \
    && rm -rf /var/lib/apt/lists/*

# 配置pip清华镜像源
RUN pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple \
    && pip config set install.trusted-host pypi.tuna.tsinghua.edu.cn

# 复制依赖清单
COPY requirements.txt .

# 安装Python依赖（增加--no-cache-dir避免缓存）
RUN pip install --no-cache-dir -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

# 复制应用代码
COPY ./app ./app

# 设置安全限制
ENV PYTHONUNBUFFERED=1
ENV PYTHONPATH=/app

# 暴露端口
EXPOSE 4323

# 启动命令
ENTRYPOINT [ "uvicorn" ]
CMD [ "app.executor_fastapi:app", "--host", "0.0.0.0", "--port", "4323", "--timeout-keep-alive", "360"]
