diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..7dad3b1 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,73 @@ +# Python +__pycache__/ +*.py[cod] +*$py.class +*.so +.Python +env/ +venv/ +ENV/ +*.egg-info/ +dist/ +build/ +.pytest_cache/ + +# Node +node_modules/ +npm-debug.log* +yarn-debug.log* +yarn-error.log* +.npm +.eslintcache + +# IDE +.vscode/ +.idea/ +*.swp +*.swo +*~ + +# OS +.DS_Store +Thumbs.db + +# 环境变量文件 +.env +.env.local +.env.*.local + +# 数据库文件(不包含在镜像中) +data/*.db +backend/data/*.db + +# 日志文件 +logs/ +*.log + +# Git +.git/ +.gitignore +.gitattributes + +# 文档 +docs/ +*.md +!README.md + +# 测试 +tests/ +test/ +*.test.js +*.spec.js + +# 前端构建文件(会在Docker内部构建) +frontend/dist/ +frontend/build/ + +# 后端静态文件(会从前端构建阶段复制) +backend/static/ + +# Docker相关 +Dockerfile +.dockerignore +docker-compose*.yml \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d36db68 --- /dev/null +++ b/.gitignore @@ -0,0 +1,105 @@ +# Python +__pycache__/ +*.py[cod] +*$py.class +*.so +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# Virtual Environment +venv/ +ENV/ +env/ +.venv + +# IDE +.vscode/ +.idea/ +*.swp +*.swo +*~ +.DS_Store + +# Environment variables +.env +.env.local +.env.*.local + +# Database files +*.db +*.db-shm +*.db-wal +*.sqlite +*.sqlite3 + +# Logs +*.log +logs/ +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* + +# Node.js +node_modules/ +.npm +.eslintcache + +# Build outputs +dist/ +build/ +backend/static/ + +# OS +Thumbs.db +.DS_Store +*.tmp + +# User data +backend/data/*.db +backend/data/*.db-shm +backend/data/*.db-wal +backend/data/users.json +backend/data/admins.json + +# Temporary files +*.bak +*.swp +*.tmp +.temp/ +temp/ +tmp/ + +# Coverage +.coverage +htmlcov/ +*.cover +.hypothesis/ +.pytest_cache/ + +# Type checking +.mypy_cache/ +.dmypy.json +dmypy.json + +# Jupyter Notebook +.ipynb_checkpoints + +data/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..60a4447 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,71 @@ +# 多阶段构建 Dockerfile for AI Story Creator +# 阶段1: 构建前端 +FROM node:22-alpine AS frontend-builder + +WORKDIR /frontend + +# 复制前端依赖文件 +COPY frontend/package*.json ./ + +# 使用国内npm镜像加速 +RUN npm config set registry https://registry.npmmirror.com + +# 安装依赖 +RUN npm install + +# 复制前端源代码 +COPY frontend/ ./ + +# 临时修改vite配置,使其输出到dist目录(而不是../backend/static) +RUN sed -i "s|outDir: '../backend/static'|outDir: 'dist'|g" vite.config.ts + +# 构建前端 +RUN npm run build + +# 阶段2: 构建最终镜像 +FROM python:3.11-slim + +# 设置工作目录 +WORKDIR /app + +# 使用国内镜像源加速 +RUN sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list.d/debian.sources \ + && sed -i 's/security.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list.d/debian.sources + +# 安装系统依赖 +RUN apt-get update && apt-get install -y \ + gcc \ + && rm -rf /var/lib/apt/lists/* + +# 复制后端依赖文件 +COPY backend/requirements.txt ./ + +# 安装Python依赖 +RUN pip install --no-cache-dir -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/ + +# 复制后端代码 +COPY backend/ ./ + +# 从前端构建阶段复制构建好的静态文件 +COPY --from=frontend-builder /frontend/dist ./static + +# 创建必要的目录 +RUN mkdir -p /app/data /app/logs + +# 复制环境变量示例文件 +COPY backend/.env.example ./.env.example + +# 暴露端口 +EXPOSE 8000 + +# 设置环境变量 +ENV PYTHONUNBUFFERED=1 +ENV APP_HOST=0.0.0.0 +ENV APP_PORT=8000 + +# 健康检查 +HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ + CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')" || exit 1 + +# 启动命令 +CMD ["python", "-m", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"] \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..32ec7dc --- /dev/null +++ b/README.md @@ -0,0 +1,600 @@ +# MuMuAINovel 📚✨ + +
AI将根据以下信息创作本章内容:
++ ⚠️ 注意:此操作将覆盖当前章节内容 +
++ 将AI生成的文本变得更自然、更像人类作家的手笔 +
+ +