# TH Agenter 后端 Docker 镜像 FROM python:3.11-slim WORKDIR /app # 安装系统依赖(PDF、文档处理等) RUN apt-get update && apt-get install -y --no-install-recommends \ gcc \ libpq-dev \ && rm -rf /var/lib/apt/lists/* # 复制依赖文件(排除 Windows 专用包 win32_setctime) COPY requirements.txt . RUN grep -v '^win32_setctime' requirements.txt > /tmp/requirements.txt \ && pip install --no-cache-dir -r /tmp/requirements.txt # 复制项目代码 COPY . . # 创建数据目录 RUN mkdir -p /app/data/uploads /app/data/chroma /app/webIOs/output/logs # 暴露端口 EXPOSE 8000 # 启动命令:先执行数据库迁移,再启动 uvicorn CMD ["sh", "-c", "alembic upgrade head 2>/dev/null || true && uvicorn main:app --host 0.0.0.0 --port 8000"]