Skip to content
Merged
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ docs/
doc/
uploads/
backend/uploads/
HANDOFF.md

# Environment variables (may contain secrets)
.env
Expand Down
10 changes: 6 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ WORKDIR /app
# 启用 pnpm(与项目包管理一致)
RUN corepack enable && corepack prepare pnpm@latest --activate

# 先复制后端代码(.dockerignore 已排除 node_modules),再安装依赖
# 先复制后端代码(.dockerignore 已排除 node_modules),安装全部依赖(含 typescript/tsx 以便编译)
COPY backend/ ./backend/
RUN cd backend && pnpm install --prod
RUN cd backend && pnpm install
# 编译 TypeScript -> dist/(生产运行 dist/index.js)
RUN cd backend && pnpm run build

# 再复制前端代码,安装依赖并构建(同源部署时 API 使用相对路径)
COPY frontend/ ./frontend/
Expand All @@ -26,5 +28,5 @@ EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \
CMD node -e "fetch('http://localhost:3000/health').then(r=>r.ok?process.exit(0):process.exit(1)).catch(()=>process.exit(1))"

# 从项目根 /app 启动后端(后端通过 __dirname 解析 backend/.env 路径)
CMD ["node", "backend/src/index.js"]
# 从项目根 /app 启动后端(运行 tsc 编译产物 dist/index.js,后端通过 __dirname 解析 backend/.env 路径)
CMD ["node", "backend/dist/index.js"]
13 changes: 11 additions & 2 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
"description": "",
"main": "index.js",
"scripts": {
"start": "cross-env NODE_ENV=production node src/index.js",
"dev": "cross-env NODE_ENV=development node src/index.js",
"start": "cross-env NODE_ENV=production node dist/index.js",
"dev": "cross-env NODE_ENV=development tsx watch src/index.ts",
"build": "tsc -p tsconfig.build.json",
"typecheck": "tsc --noEmit",
"test": "vitest run",
"test:watch": "vitest",
"test:coverage": "vitest run --coverage"
Expand Down Expand Up @@ -36,8 +38,15 @@
"uuid": "^13.0.0"
},
"devDependencies": {
"@types/cors": "^2.8.19",
"@types/express": "^5.0.6",
"@types/jsonwebtoken": "^9.0.10",
"@types/multer": "^2.2.0",
"@types/node": "^26.1.1",
"@vitest/coverage-v8": "^3.1.1",
"cross-env": "^7.0.3",
"tsx": "^4.23.0",
"typescript": "^7.0.2",
"vitest": "^3.1.1"
}
}
Loading
Loading