chore: 第六组工程化统一
- Dockerfile: node:18-slim 升级 node:20-slim(LTS,better-sqlite3 有预编译二进制) - engines 统一 node >=20.19.0(对齐 Vite 8 要求,前后端一致) - backend 新增 npm test(node --test,自动发现 test/ 目录) - 新增 .github/workflows/ci.yml:后端 npm test + 前端 build - 提交 frontend/package-lock.json,CI 依赖缓存生效
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
backend-test:
|
||||
name: Backend tests
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: backend
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
cache: npm
|
||||
cache-dependency-path: backend/package-lock.json
|
||||
- run: npm install --registry=https://registry.npmmirror.com
|
||||
- run: npm test
|
||||
|
||||
frontend-build:
|
||||
name: Frontend build
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: frontend
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
cache: npm
|
||||
cache-dependency-path: frontend/package-lock.json
|
||||
- run: npm install --registry=https://registry.npmmirror.com
|
||||
- run: npm run build
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
# 本地已构建好 frontend/dist,镜像内无需 pnpm/corepack/构建工具链
|
||||
FROM --platform=linux/amd64 node:18-slim
|
||||
# 本地已构建好 frontend/dist,镜像内无需构建工具链
|
||||
FROM --platform=linux/amd64 node:20-slim
|
||||
ENV NODE_ENV=production \
|
||||
PORT=3000 \
|
||||
DATA_DIR=/app/data \
|
||||
@@ -7,7 +7,7 @@ ENV NODE_ENV=production \
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# 后端依赖:仅 express + better-sqlite3(node:18 有预编译二进制)
|
||||
# 后端依赖:仅 express + better-sqlite3(node:20 有预编译二进制)
|
||||
COPY backend/package.json ./
|
||||
RUN npm install --production
|
||||
|
||||
|
||||
@@ -4,12 +4,13 @@
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "server.js",
|
||||
"scripts": {
|
||||
"scripts": {
|
||||
"start": "node server.js",
|
||||
"dev": "node --watch server.js"
|
||||
"dev": "node --watch server.js",
|
||||
"test": "node --test"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
"node": ">=20.19.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"better-sqlite3": "^11.10.0",
|
||||
|
||||
Generated
+1722
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,10 @@
|
||||
"name": "frontend",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"type": "module",
|
||||
"engines": {
|
||||
"node": ">=20.19.0"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
|
||||
Reference in New Issue
Block a user