- 新增 GitHub Issue 模板(Bug 报告、功能请求)和 Pull Request 模板 - 新增 Code of Conduct(贡献者行为准则)和 Security Policy(安全政策) - 新增 CI 工作流(GitHub Actions),包含 ruff 代码检查和导入验证 - 新增开发依赖文件 requirements-dev.txt 📦 build(ci): 配置 GitHub Actions 持续集成 - 在 push 到 main 分支和 pull request 时自动触发 CI - 添加 lint 任务执行 ruff 代码风格检查 - 添加 import-check 任务验证核心服务模块导入 ♻️ refactor(structure): 重构项目目录结构 - 将根目录的 6 个服务模块迁移至 services/ 包 - 更新所有相关文件的导入语句(main.py、ui/、services/) - 根目录仅保留 main.py 作为唯一 Python 入口文件 🔧 chore(config): 调整配置和资源文件路径 - 将 config.json 移至 config/ 目录,更新相关引用 - 将个人头像图片移至 assets/faces/ 目录,更新 .gitignore - 更新 Dockerfile 和 docker-compose.yml 中的配置路径 📝 docs(readme): 完善 README 文档 - 添加项目状态徽章(Python 版本、License、CI) - 更新项目结构图反映实际目录布局 - 修正使用指南中的 Tab 名称和操作路径 - 替换 your-username 占位符为格式提示 🗑️ chore(cleanup): 清理冗余文件 - 删除旧版备份文件、测试脚本、临时记录和运行日志 - 删除散落的个人图片文件(已归档至 assets/faces/)
52 lines
1.2 KiB
Docker
52 lines
1.2 KiB
Docker
# ---------- 构建阶段 ----------
|
||
FROM python:3.11-slim AS builder
|
||
|
||
WORKDIR /app
|
||
|
||
# 安装构建依赖(matplotlib 需要)
|
||
RUN apt-get update && \
|
||
apt-get install -y --no-install-recommends gcc && \
|
||
rm -rf /var/lib/apt/lists/*
|
||
|
||
COPY requirements.txt .
|
||
RUN pip install --no-cache-dir --prefix=/install -r requirements.txt
|
||
|
||
# ---------- 运行阶段 ----------
|
||
FROM python:3.11-slim
|
||
|
||
LABEL maintainer="xhs-autobot"
|
||
LABEL description="小红书 AI 爆文生产工坊"
|
||
|
||
WORKDIR /app
|
||
|
||
# matplotlib 中文字体 + 运行时依赖
|
||
RUN apt-get update && \
|
||
apt-get install -y --no-install-recommends fonts-noto-cjk curl && \
|
||
rm -rf /var/lib/apt/lists/*
|
||
|
||
# 从构建阶段复制 Python 包
|
||
COPY --from=builder /install /usr/local
|
||
|
||
# 复制项目代码
|
||
COPY main.py requirements.txt ./
|
||
COPY services/ services/
|
||
COPY ui/ ui/
|
||
COPY config/config.example.json config/config.example.json
|
||
|
||
# 创建工作目录
|
||
RUN mkdir -p xhs_workspace config logs
|
||
|
||
# Gradio 默认端口
|
||
EXPOSE 7860
|
||
|
||
# 环境变量
|
||
ENV GRADIO_SERVER_NAME="0.0.0.0"
|
||
ENV GRADIO_SERVER_PORT="7860"
|
||
ENV PYTHONUNBUFFERED=1
|
||
ENV MPLCONFIGDIR=/tmp/matplotlib
|
||
|
||
HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
|
||
CMD curl -f http://localhost:7860/ || exit 1
|
||
|
||
CMD ["python", "main.py"]
|