```
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Failing after 1s

docs(.gitignore/README/QUICKSTART): 更新文档和忽略配置

- 添加IDE配置、日志和数据文件到.gitignore
- 重构QUICKSTART.md,提供Docker Compose和本地开发两种部署方式
- 更新README.md,优化项目介绍和架构说明
- 移除旧的agent.py和backend.py文件
```
This commit is contained in:
2026-04-13 23:57:16 +08:00
parent bf27398cc9
commit 22cc9b1096
20 changed files with 714 additions and 481 deletions

22
docker/Dockerfile.backend Normal file
View File

@@ -0,0 +1,22 @@
FROM python:3.11-slim
WORKDIR /app
# 复制依赖文件并安装(利用 Docker 层缓存)
COPY requirement.txt .
RUN pip install --no-cache-dir -r requirement.txt
# 复制项目代码
COPY app/ ./app/
COPY frontend/ ./frontend/
COPY data/ ./data/
COPY scripts/ ./scripts/
# 设置 PYTHONPATH 确保模块能被找到
ENV PYTHONPATH=/app
# 暴露端口(文档用途)
EXPOSE 8001
# 启动命令
CMD ["python", "app/backend.py"]

View File

@@ -0,0 +1,15 @@
FROM python:3.11-slim
WORKDIR /app
COPY requirement.txt .
RUN pip install --no-cache-dir -r requirement.txt
COPY frontend/ ./frontend/
COPY app/ ./app/
ENV PYTHONPATH=/app
EXPOSE 8501
CMD ["streamlit", "run", "frontend/frontend.py", "--server.port", "8501", "--server.address", "0.0.0.0"]

63
docker/docker-compose.yml Normal file
View File

@@ -0,0 +1,63 @@
version: '3.8'
services:
postgres:
image: postgres:16
container_name: ai-postgres
environment:
POSTGRES_PASSWORD: mysecretpassword # 请替换为强密码
POSTGRES_DB: langgraph_db
volumes:
- pg_data:/var/lib/postgresql/data
networks:
- ai-network
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5
restart: unless-stopped
# 如需外部访问数据库,取消下面注释
# ports:
# - "5432:5432"
backend:
build:
context: .. # 构建上下文为项目根目录
dockerfile: docker/Dockerfile.backend
container_name: ai-backend
environment:
- ZHIPUAI_API_KEY=${ZHIPUAI_API_KEY}
- VLLM_LOCAL_KEY=${VLLM_LOCAL_KEY}
- DB_URI=postgresql://postgres:mysecretpassword@postgres:5432/langgraph_db?sslmode=disable
volumes:
- ../data/user_docs:/app/data/user_docs # 挂载文档目录
- ../logs:/app/logs
networks:
- ai-network
depends_on:
postgres:
condition: service_healthy
restart: unless-stopped
frontend:
build:
context: ..
dockerfile: docker/Dockerfile.frontend
container_name: ai-frontend
environment:
- API_URL=http://backend:8001/chat
ports:
- "8501:8501"
networks:
- ai-network
depends_on:
- backend
restart: unless-stopped
networks:
ai-network:
driver: bridge
volumes:
pg_data: