# Docker 启动与部署说明 ## 固定入口 本项目固定使用 Docker Compose 项目名 `hot-comments-tool`,服务入口固定为: ```bash http://localhost:8000 ``` 启动或重建: ```bash docker compose up -d --build curl -f http://localhost:8000/health ``` 查看容器: ```bash docker compose ps ``` 正常情况下只需要看到一个应用容器:`hot-comments-tool-app-1`。 ## 端口占用排查 如果 `8000` 被占用,先确认是不是本项目容器: ```bash lsof -nP -iTCP:8000 -sTCP:LISTEN docker compose ps ``` 如果是旧的同项目容器,执行: ```bash docker compose down docker compose up -d --build ``` 不要临时改到 `8001`,否则浏览器验收和文档记录会混乱。 ## 环境变量 Docker Compose 读取 `.env`,不要把真实 `.env` 提交到 Git。 首次启动前可以从示例文件复制: ```bash cp .env.example .env ``` 必须配置: ```text TIKHUB_API_KEY= AI_BASE_URL= AI_API_KEY= AI_MODEL= ``` ## 数据目录 SQLite 数据固定挂载整个目录: ```yaml ./data:/app/data ``` 不要只挂载单个 `app.db` 文件。SQLite WAL 模式会生成: ```text data/app.db data/app.db-wal data/app.db-shm ``` 这三个文件必须在同一个挂载目录内。 ## 重置本地验收数据库 仅在确认不需要保留历史任务后执行: ```bash docker compose down rm -f data/app.db data/app.db-wal data/app.db-shm docker compose up -d --build curl -f http://localhost:8000/health ``` 重置后历史任务会消失,首页任务列表会从空状态开始。 ## 验收命令 ```bash .venv/bin/python -m pytest tests/unit tests/integration -q docker compose up -d --build curl -f http://localhost:8000/health ```