Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 121 additions & 7 deletions .dockerignore
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.*
17 changes: 16 additions & 1 deletion .prettierrc
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",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Potential formatting inconsistency across workspace apps.

The root Prettier config sets trailingComma: "es5", but according to the PR context, apps/server/.prettierrc uses trailingComma: "all". This could lead to inconsistent formatting between the server app and other apps in the monorepo.

Consider:

  1. Standardizing trailingComma across all apps, or
  2. Documenting the intentional per-app formatting differences
🤖 Prompt for AI Agents
.prettierrc around line 10: the root Prettier config uses "trailingComma": "es5"
while apps/server/.prettierrc uses "trailingComma": "all", causing inconsistent
formatting; either update the root .prettierrc to use "trailingComma": "all" so
all workspace apps inherit the same rule, or explicitly document and keep
per-app differences by adding a note in the repository README (or a new
docs/formatting.md) explaining which apps override the root and why, and ensure
each app-level .prettierrc explicitly declares its trailingComma value to avoid
ambiguity.

"printWidth": 80,
"arrowParens": "always",
"bracketSameLine": false,
"embeddedLanguageFormatting": "auto",
"insertPragma": false,
"proseWrap": "preserve",
"quoteProps": "as-needed",
"requirePragma": false
}
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"cSpell.words": ["metatype"],
"cSpell.words": ["metatype", "fengzai", "tailwindcss"],
"editor.detectIndentation": false,
"editor.tabSize": 2,
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit",
"source.fixAll.eslint": "explicit"
Expand Down
52 changes: 0 additions & 52 deletions Dockerfile

This file was deleted.

102 changes: 102 additions & 0 deletions Dockerfile.bak
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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

Verify pnpm prune --prod behavior in monorepo.

In a PNPM workspace (monorepo), pnpm prune --prod may not work as expected. The command needs to be run with workspace awareness.

Consider using pnpm install --prod --frozen-lockfile in a fresh stage instead of pruning, or verify that pnpm prune --prod correctly handles workspace dependencies.


🏁 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:

Does pnpm prune --prod work correctly in PNPM workspaces?

💡 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:

  • pnpm prune docs (notes that prune does not support recursive execution on a monorepo). [1]
  • pnpm docs (9.x / warning repeated). [2]

Fix pnpm prune --prod command for workspace environment.

In a PNPM workspace (monorepo), pnpm prune --prod does not support recursive execution and will not work as expected. The Dockerfile copies workspace configuration files, indicating a monorepo setup where this command will fail to properly prune development dependencies.

Replace with: pnpm install --prod --frozen-lockfile on a fresh stage, or use per-workspace commands.

🤖 Prompt for AI Agents
In Dockerfile.bak around lines 58 to 68, the use of "pnpm prune --prod" in a
PNPM workspace is incorrect because prune is not recursive and won't remove dev
deps in a monorepo; instead run a production install that respects the workspace
lockfile or prune per-package. Replace the prune step by performing a fresh
production install with "pnpm install --prod --frozen-lockfile" in a clean stage
(or loop/execute per-workspace/package installs for apps/server) so only
production dependencies are installed, ensuring you copy only needed
node_modules into the final image.


# ===========================================
# 最终生产镜像
# ===========================================
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"]
Loading