-
Notifications
You must be signed in to change notification settings - Fork 3
Refactor/monorepo #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,128 @@ | ||
| # =========================================== | ||
| # Dependencies (will be installed in Docker) | ||
| # =========================================== | ||
| node_modules | ||
| */node_modules | ||
| apps/*/node_modules | ||
| packages/*/node_modules | ||
|
|
||
| # =========================================== | ||
| # Build outputs (will be built in Docker) | ||
| # =========================================== | ||
| dist | ||
| build | ||
| .next | ||
| apps/*/dist | ||
| apps/*/build | ||
| apps/*/.next | ||
| apps/docs/.vitepress/dist | ||
| apps/docs/.vitepress/cache | ||
|
|
||
| # =========================================== | ||
| # Git and Version Control | ||
| # =========================================== | ||
| .git | ||
| .gitignore | ||
| .env | ||
| .gitattributes | ||
|
|
||
| # =========================================== | ||
| # Environment files | ||
| # =========================================== | ||
| .env* | ||
| !.env.example | ||
|
|
||
| # =========================================== | ||
| # IDE and Editor files | ||
| # =========================================== | ||
| .vscode | ||
| .idea | ||
| *.swp | ||
| *.swo | ||
| *.sublime-* | ||
| .editorconfig | ||
|
|
||
| # =========================================== | ||
| # OS files | ||
| # =========================================== | ||
| .DS_Store | ||
| Thumbs.db | ||
| desktop.ini | ||
|
|
||
| # =========================================== | ||
| # Logs | ||
| # =========================================== | ||
| logs | ||
| *.log | ||
| *.md | ||
| npm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* | ||
| pnpm-debug.log* | ||
|
|
||
| # docker | ||
| docker | ||
| # =========================================== | ||
| # Test and Coverage | ||
| # =========================================== | ||
| coverage | ||
| *.lcov | ||
| .nyc_output | ||
| **/*.test.ts | ||
| **/*.spec.ts | ||
| **/*.e2e-spec.ts | ||
| test/ | ||
| tests/ | ||
|
|
||
| # =========================================== | ||
| # Docker related | ||
| # =========================================== | ||
| Dockerfile* | ||
| docker-compose*.yml | ||
| .dockerignore | ||
| docker/ | ||
|
|
||
| # =========================================== | ||
| # CI/CD | ||
| # =========================================== | ||
| .github | ||
| .gitlab-ci.yml | ||
| .circleci | ||
| .travis.yml | ||
|
|
||
| # =========================================== | ||
| # Temporary files | ||
| # =========================================== | ||
| tmp | ||
| temp | ||
| *.tmp | ||
| *.temp | ||
|
|
||
| # =========================================== | ||
| # Package manager lock files | ||
| # =========================================== | ||
| # Keep pnpm-lock.yaml, ignore others | ||
| package-lock.json | ||
| yarn.lock | ||
|
|
||
| # =========================================== | ||
| # Cache directories | ||
| # =========================================== | ||
| .cache | ||
| .parcel-cache | ||
| .eslintcache | ||
| .turbo | ||
| .swc | ||
|
|
||
| # =========================================== | ||
| # Documentation (keep critical files) | ||
| # =========================================== | ||
| apps/docs/ | ||
| *.md | ||
| !README.md | ||
|
|
||
| # client | ||
| client/node_modules | ||
| client/dist | ||
| # =========================================== | ||
| # Miscellaneous | ||
| # =========================================== | ||
| .husky | ||
| .commitlintrc* | ||
| .prettierrc* | ||
| .eslintrc* | ||
| eslint.config.* | ||
| prettier.config.* |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,19 @@ | ||
| { | ||
| "semi": true, | ||
| "singleQuote": true, | ||
| "trailingComma": "all" | ||
| "tabWidth": 2, | ||
| "useTabs": false, | ||
| "bracketSpacing": true, | ||
| "endOfLine": "auto", | ||
| "htmlWhitespaceSensitivity": "ignore", | ||
| "jsxSingleQuote": false, | ||
| "trailingComma": "es5", | ||
| "printWidth": 80, | ||
| "arrowParens": "always", | ||
| "bracketSameLine": false, | ||
| "embeddedLanguageFormatting": "auto", | ||
| "insertPragma": false, | ||
| "proseWrap": "preserve", | ||
| "quoteProps": "as-needed", | ||
| "requirePragma": false | ||
| } | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| # =========================================== | ||
| # 基础镜像 - 包含 Node.js 和 pnpm | ||
| # =========================================== | ||
| FROM node:22-slim AS base | ||
| ENV PNPM_HOME="/pnpm" | ||
| ENV PATH="$PNPM_HOME:$PATH" | ||
| RUN corepack enable | ||
| WORKDIR /app | ||
|
|
||
| # =========================================== | ||
| # 依赖安装阶段 - 安装所有依赖用于构建 | ||
| # =========================================== | ||
| FROM base AS deps | ||
| # 复制 workspace 配置文件 | ||
| COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./ | ||
| # 复制各个应用的 package.json | ||
| COPY apps/server/package.json ./apps/server/ | ||
| COPY apps/web/package.json ./apps/web/ | ||
|
|
||
| # 安装所有依赖(包括开发依赖,用于构建) | ||
| RUN pnpm install --frozen-lockfile | ||
|
|
||
| # =========================================== | ||
| # 后端构建阶段 | ||
| # =========================================== | ||
| FROM base AS server-builder | ||
| # 复制依赖 | ||
| COPY --from=deps /app/node_modules ./node_modules | ||
| COPY --from=deps /app/apps/server/node_modules ./apps/server/node_modules | ||
|
|
||
| # 复制后端源代码和配置 | ||
| COPY package.json pnpm-workspace.yaml ./ | ||
| COPY apps/server ./apps/server | ||
|
|
||
| # 构建后端 | ||
| WORKDIR /app/apps/server | ||
| RUN pnpm build | ||
|
|
||
| # =========================================== | ||
| # 前端构建阶段 | ||
| # =========================================== | ||
| FROM base AS web-builder | ||
| # 复制依赖 | ||
| COPY --from=deps /app/node_modules ./node_modules | ||
| COPY --from=deps /app/apps/web/node_modules ./apps/web/node_modules | ||
|
|
||
| # 复制前端源代码和配置 | ||
| COPY package.json pnpm-workspace.yaml ./ | ||
| COPY apps/web ./apps/web | ||
|
|
||
| # 构建前端 | ||
| WORKDIR /app/apps/web | ||
| RUN pnpm build | ||
|
|
||
| # =========================================== | ||
| # 生产依赖准备阶段 - 从完整依赖中移除开发依赖 | ||
| # =========================================== | ||
| FROM base AS prod-deps | ||
| # 复制完整的依赖(包括已编译的原生模块) | ||
| COPY --from=deps /app/node_modules ./node_modules | ||
| COPY --from=deps /app/apps/server/node_modules ./apps/server/node_modules | ||
|
|
||
| # 复制 workspace 配置文件 | ||
| COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./ | ||
| COPY apps/server/package.json ./apps/server/ | ||
|
|
||
| # 移除开发依赖,保留生产依赖 | ||
| RUN pnpm prune --prod | ||
|
Comment on lines
+58
to
+68
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainVerify In a PNPM workspace (monorepo), Consider using 🏁 Script executed: #!/bin/bash
# Description: Check PNPM documentation for prune command in workspaces
echo "Searching for PNPM prune documentation..."
echo "Note: In PNPM workspaces, 'pnpm prune' may not work as expected."
echo "Consider using: pnpm install --prod --frozen-lockfile instead"Length of output: 168 🌐 Web query: 💡 Result: Short answer: No — pnpm prune --prod is not supported to run recursively across a workspace/monorepo. Use per-workspace commands or remove node_modules and run pnpm install --prod instead. [1][2] Sources:
Fix In a PNPM workspace (monorepo), Replace with: 🤖 Prompt for AI Agents |
||
|
|
||
| # =========================================== | ||
| # 最终生产镜像 | ||
| # =========================================== | ||
| FROM base AS production | ||
|
|
||
| # 设置环境变量 | ||
| ENV NODE_ENV=production | ||
|
|
||
| # 复制 workspace 配置 | ||
| COPY package.json pnpm-workspace.yaml ./ | ||
| COPY apps/server/package.json ./apps/server/ | ||
|
|
||
| # 从生产依赖阶段复制 node_modules | ||
| COPY --from=prod-deps /app/node_modules ./node_modules | ||
| COPY --from=prod-deps /app/apps/server/node_modules ./apps/server/node_modules | ||
|
|
||
| # 从后端构建阶段复制构建产物 | ||
| COPY --from=server-builder /app/apps/server/dist ./apps/server/dist | ||
| COPY --from=server-builder /app/apps/server/database ./apps/server/database | ||
|
|
||
| # 从前端构建阶段复制构建产物 | ||
| COPY --from=web-builder /app/apps/web/dist ./apps/web/dist | ||
|
|
||
| # 复制启动脚本 | ||
| COPY scripts/start.sh ./scripts/start.sh | ||
| # 修复 Windows 换行符 (CRLF) 问题并添加可执行权限 | ||
| RUN sed -i 's/\r$//' ./scripts/start.sh && chmod +x ./scripts/start.sh | ||
|
|
||
| # 暴露端口(根据实际配置调整) | ||
| EXPOSE 3000 | ||
|
|
||
| # 启动应用 | ||
| CMD ["sh", "./scripts/start.sh"] | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential formatting inconsistency across workspace apps.
The root Prettier config sets
trailingComma: "es5", but according to the PR context,apps/server/.prettierrcusestrailingComma: "all". This could lead to inconsistent formatting between the server app and other apps in the monorepo.Consider:
trailingCommaacross all apps, or🤖 Prompt for AI Agents