Compare commits

...

5 Commits

Author SHA1 Message Date
5e0c87768c chore(frontend): 更新依赖锁文件和组件类型声明
- package-lock.json:本地 npm install 后依赖树更新
- components.d.ts:unplugin-vue-components 自动生成的
  组件类型声明同步更新
2026-02-28 19:33:01 +08:00
0b3998489d feat(deploy): 添加 docker-compose 一键部署配置
定义 backend 和 frontend 两个服务:
- backend 监听 3001 端口,设置 Prisma OpenSSL 3.x 环境变量,
  JWT_SECRET 通过宿主机环境变量注入避免硬编码
- frontend 监听 8080 端口,depends_on backend 保证启动顺序

使用方式:
  JWT_SECRET=your-secret docker-compose up -d
2026-02-28 19:32:54 +08:00
92071e5ba6 feat(frontend): 添加 Docker 部署配置和生产环境变量
- Dockerfile:多阶段构建,node:20-alpine 编译 Vue3,
  nginx:alpine 提供静态资源服务,使用国内 npm 镜像加速
- nginx.conf:配置 Vue Router history 模式(try_files),
  /api/ 和 /uploads/ 反向代理到后端容器
- .env.production:生产环境 API 地址(8.148.151.56:3001)
- .gitignore:放开 .env.production 提交权限(无敏感信息)
2026-02-28 19:32:45 +08:00
3a921250c3 feat(backend): 添加 Docker 部署配置
- Dockerfile:基于 node:20-alpine,包含 TypeScript 编译和
  Prisma Client 生成步骤,对外暴露 3001 端口
- .env.example:提供环境变量模板,团队成员按此创建 .env 文件
  (.env 本身含敏感信息,已加入 .gitignore 不提交)
2026-02-28 19:32:14 +08:00
f056bf72a2 fix(backend): 修复 Prisma 在 Alpine Linux 容器中的 OpenSSL 兼容性问题
在 generator client 中添加 binaryTargets,显式指定
linux-musl-openssl-3.0.x,解决 Alpine Linux 3.18+ 使用
OpenSSL 3.x 时 Prisma 引擎无法加载的问题。
2026-02-28 19:32:03 +08:00
10 changed files with 84 additions and 10 deletions

3
.gitignore vendored
View File

@ -19,7 +19,8 @@ target/
# 环境变量(含敏感信息,不提交) # 环境变量(含敏感信息,不提交)
.env .env
.env.local .env.local
.env.production # .env.production 只含 API 地址,允许提交
# .env.production
# 保留开发环境配置(可按需注释掉) # 保留开发环境配置(可按需注释掉)
# .env.development # .env.development

28
docker-compose.yml Normal file
View File

@ -0,0 +1,28 @@
version: '3.8'
services:
backend:
build:
context: ./reading-platform-backend
container_name: kindergarten-backend
restart: unless-stopped
ports:
- "3001:3001"
environment:
- PORT=3001
- NODE_ENV=production
- DATABASE_URL=file:/app/prisma/dev.db
- JWT_SECRET=${JWT_SECRET:-change-this-secret}
- JWT_EXPIRES_IN=7d
- FRONTEND_URL=http://localhost:8080
- PRISMA_QUERY_ENGINE_LIBRARY=/app/node_modules/.prisma/client/libquery_engine-linux-musl-openssl-3.0.x.so.node
frontend:
build:
context: ./reading-platform-frontend
container_name: kindergarten-frontend
restart: unless-stopped
ports:
- "8080:80"
depends_on:
- backend

View File

@ -0,0 +1,6 @@
DATABASE_URL="file:/app/prisma/dev.db"
NODE_ENV=production
PORT=3001
JWT_SECRET="your-secret-key-here"
JWT_EXPIRES_IN="7d"
FRONTEND_URL="http://your-server-ip:8080"

View File

@ -0,0 +1,9 @@
FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install --registry=https://registry.npmmirror.com
COPY . .
RUN npx tsc
RUN npx prisma generate
EXPOSE 3001
CMD ["node", "dist/src/main.js"]

View File

@ -2,6 +2,7 @@
generator client { generator client {
provider = "prisma-client-js" provider = "prisma-client-js"
binaryTargets = ["native", "linux-musl-openssl-3.0.x"]
} }
datasource db { datasource db {

View File

@ -0,0 +1,3 @@
VITE_API_BASE_URL=http://8.148.151.56:3001/api/v1
VITE_SERVER_BASE_URL=http://8.148.151.56:3001
VITE_APP_TITLE=幼儿阅读教学服务平台

View File

@ -0,0 +1,14 @@
# 阶段一:编译
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm install --registry=https://registry.npmmirror.com
COPY . .
RUN npx vite build
# 阶段二Nginx 服务
FROM nginx:alpine
COPY --from=builder /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

View File

@ -0,0 +1,21 @@
server {
listen 80;
root /usr/share/nginx/html;
index index.html;
# Vue Router history 模式支持
location / {
try_files $uri $uri/ /index.html;
}
# 反向代理后端 API
location /api/ {
proxy_pass http://backend:3001;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
location /uploads/ {
proxy_pass http://backend:3001;
}
}

View File

@ -555,7 +555,6 @@
"resolved": "https://registry.npmjs.org/@fullcalendar/core/-/core-6.1.20.tgz", "resolved": "https://registry.npmjs.org/@fullcalendar/core/-/core-6.1.20.tgz",
"integrity": "sha512-1cukXLlePFiJ8YKXn/4tMKsy0etxYLCkXk8nUCFi11nRONF2Ba2CD5b21/ovtOO2tL6afTJfwmc1ed3HG7eB1g==", "integrity": "sha512-1cukXLlePFiJ8YKXn/4tMKsy0etxYLCkXk8nUCFi11nRONF2Ba2CD5b21/ovtOO2tL6afTJfwmc1ed3HG7eB1g==",
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"preact": "~10.12.1" "preact": "~10.12.1"
} }
@ -1367,7 +1366,6 @@
"integrity": "sha512-Rs1bVAIdBs5gbTIKza/tgpMuG1k3U/UMJLWecIMxNdJFDMzcM5LOiLVRYh3PilWEYDIeUDv7bpiHPLPsbydGcw==", "integrity": "sha512-Rs1bVAIdBs5gbTIKza/tgpMuG1k3U/UMJLWecIMxNdJFDMzcM5LOiLVRYh3PilWEYDIeUDv7bpiHPLPsbydGcw==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"undici-types": "~6.21.0" "undici-types": "~6.21.0"
} }
@ -2875,7 +2873,6 @@
"integrity": "sha512-oQL6lgK3e2QZeQ7gcgIkS2YZPg5slw37hYufJ3edKlfQSGGm8ICoxswK15ntSzF/a8+h7ekRy7k7oWc3BQ7y8A==", "integrity": "sha512-oQL6lgK3e2QZeQ7gcgIkS2YZPg5slw37hYufJ3edKlfQSGGm8ICoxswK15ntSzF/a8+h7ekRy7k7oWc3BQ7y8A==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"@types/estree": "1.0.8" "@types/estree": "1.0.8"
}, },
@ -2977,7 +2974,6 @@
"integrity": "sha512-eKzFy13Nk+IRHhlAwP3sfuv+PzOrvzUkwJK2hdoCKYcWGSdmwFpeGpWmyewdw8EgBnsKaSBtgf/0b2K635ecSA==", "integrity": "sha512-eKzFy13Nk+IRHhlAwP3sfuv+PzOrvzUkwJK2hdoCKYcWGSdmwFpeGpWmyewdw8EgBnsKaSBtgf/0b2K635ecSA==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"@bufbuild/protobuf": "^2.5.0", "@bufbuild/protobuf": "^2.5.0",
"colorjs.io": "^0.5.0", "colorjs.io": "^0.5.0",
@ -3489,7 +3485,6 @@
"integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==",
"devOptional": true, "devOptional": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"peer": true,
"bin": { "bin": {
"tsc": "bin/tsc", "tsc": "bin/tsc",
"tsserver": "bin/tsserver" "tsserver": "bin/tsserver"
@ -3705,7 +3700,6 @@
"integrity": "sha512-o5a9xKjbtuhY6Bi5S3+HvbRERmouabWbyUcpXXUA1u+GNUKoROi9byOJ8M0nHbHYHkYICiMlqxkg1KkYmm25Sw==", "integrity": "sha512-o5a9xKjbtuhY6Bi5S3+HvbRERmouabWbyUcpXXUA1u+GNUKoROi9byOJ8M0nHbHYHkYICiMlqxkg1KkYmm25Sw==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"esbuild": "^0.21.3", "esbuild": "^0.21.3",
"postcss": "^8.4.43", "postcss": "^8.4.43",
@ -3787,7 +3781,6 @@
"resolved": "https://registry.npmjs.org/vue/-/vue-3.5.28.tgz", "resolved": "https://registry.npmjs.org/vue/-/vue-3.5.28.tgz",
"integrity": "sha512-BRdrNfeoccSoIZeIhyPBfvWSLFP4q8J3u8Ju8Ug5vu3LdD+yTM13Sg4sKtljxozbnuMu1NB1X5HBHRYUzFocKg==", "integrity": "sha512-BRdrNfeoccSoIZeIhyPBfvWSLFP4q8J3u8Ju8Ug5vu3LdD+yTM13Sg4sKtljxozbnuMu1NB1X5HBHRYUzFocKg==",
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"@vue/compiler-dom": "3.5.28", "@vue/compiler-dom": "3.5.28",
"@vue/compiler-sfc": "3.5.28", "@vue/compiler-sfc": "3.5.28",

View File

@ -71,8 +71,6 @@ declare module 'vue' {
ATabs: typeof import('ant-design-vue/es')['Tabs'] ATabs: typeof import('ant-design-vue/es')['Tabs']
ATag: typeof import('ant-design-vue/es')['Tag'] ATag: typeof import('ant-design-vue/es')['Tag']
ATextarea: typeof import('ant-design-vue/es')['Textarea'] ATextarea: typeof import('ant-design-vue/es')['Textarea']
ATimeline: typeof import('ant-design-vue/es')['Timeline']
ATimelineItem: typeof import('ant-design-vue/es')['TimelineItem']
ATimeRangePicker: typeof import('ant-design-vue/es')['TimeRangePicker'] ATimeRangePicker: typeof import('ant-design-vue/es')['TimeRangePicker']
ATooltip: typeof import('ant-design-vue/es')['Tooltip'] ATooltip: typeof import('ant-design-vue/es')['Tooltip']
ATypographyText: typeof import('ant-design-vue/es')['TypographyText'] ATypographyText: typeof import('ant-design-vue/es')['TypographyText']