Update project configuration and structure with Docker support and environment variable adjustments

- Updated .env.example to reflect new LLM configuration with Aliyun's API.
- Enhanced .gitignore to include additional files and directories for better exclusion of sensitive and build artifacts.
- Added docker-compose.yml for streamlined deployment of backend and frontend services.
- Introduced Dockerfiles for both backend and frontend to facilitate containerized builds.
- Created README.md to provide comprehensive project documentation and setup instructions.
- Established nginx configuration for frontend to support API proxying and static file serving.
This commit is contained in:
666ghj
2025-12-17 18:17:40 +08:00
parent e2b1a1554d
commit e432e223df
10 changed files with 517 additions and 36 deletions

59
backend/Dockerfile Normal file
View File

@@ -0,0 +1,59 @@
# MiroFish Backend Dockerfile
# Multi-stage build for smaller image size
# ============= Build Stage =============
FROM python:3.11-slim AS builder
WORKDIR /app
# 安装构建依赖
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# 复制依赖文件
COPY requirements.txt .
# 创建虚拟环境并安装依赖
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# ============= Production Stage =============
FROM python:3.11-slim
WORKDIR /app
# 安装运行时依赖
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
&& rm -rf /var/lib/apt/lists/*
# 从 builder 复制虚拟环境
COPY --from=builder /opt/venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
# 复制应用代码
COPY app/ ./app/
COPY scripts/ ./scripts/
COPY run.py .
# 创建上传目录
RUN mkdir -p uploads/simulations uploads/reports
# 设置环境变量
ENV PYTHONUNBUFFERED=1
ENV FLASK_HOST=0.0.0.0
ENV FLASK_PORT=5001
# 暴露端口
EXPOSE 5001
# 健康检查
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:5001/health || exit 1
# 启动命令
CMD ["python", "run.py"]

53
backend/pyproject.toml Normal file
View File

@@ -0,0 +1,53 @@
[project]
name = "mirofish-backend"
version = "1.0.0"
description = "MiroFish - 简洁通用的群体智能引擎,预测万物"
readme = "README.md"
requires-python = ">=3.11"
license = { text = "MIT" }
authors = [
{ name = "MiroFish Team" }
]
dependencies = [
# 核心框架
"flask>=3.0.0",
"flask-cors>=6.0.0",
# LLM 相关
"openai>=1.0.0",
# Zep Cloud
"zep-cloud==3.13.0",
# OASIS 社交媒体模拟
"camel-oasis==0.2.5",
"camel-ai==0.2.78",
# 文件处理
"PyMuPDF>=1.24.0",
# 工具库
"python-dotenv>=1.0.0",
"pydantic>=2.0.0",
]
[project.optional-dependencies]
dev = [
"pytest>=8.0.0",
"pytest-asyncio>=0.23.0",
"pipreqs>=0.5.0",
]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[tool.uv]
dev-dependencies = [
"pytest>=8.0.0",
"pytest-asyncio>=0.23.0",
]
[tool.hatch.build.targets.wheel]
packages = ["app"]

View File

@@ -1,31 +1,32 @@
# Flask框架
# ===========================================
# MiroFish Backend Dependencies
# ===========================================
# Python 3.11+ required
# Install: pip install -r requirements.txt
# ===========================================
# ============= 核心框架 =============
flask>=3.0.0
flask-cors>=4.0.0
flask-cors>=6.0.0
# Zep Cloud SDK
zep-cloud>=2.0.0
# OpenAI SDK用于LLM调用
# ============= LLM 相关 =============
# OpenAI SDK统一使用 OpenAI 格式调用 LLM
openai>=1.0.0
# PDF处理
# ============= Zep Cloud =============
zep-cloud==3.13.0
# ============= OASIS 社交媒体模拟 =============
# OASIS 社交模拟框架
camel-oasis==0.2.5
camel-ai==0.2.78
# ============= 文件处理 =============
PyMuPDF>=1.24.0
# 环境变量
# ============= 工具库 =============
# 环境变量加载
python-dotenv>=1.0.0
# 数据验证
pydantic>=2.0.0
# 文件处理
werkzeug>=3.0.0
# OASIS社交媒体模拟框架
oasis-ai>=0.1.0
camel-ai>=0.2.0
# LangChain框架用于Report Agent
langchain>=0.2.0
langchain-core>=0.2.0
langchain-openai>=0.1.0