chore: update production deployment config

This commit is contained in:
2026-07-16 10:21:40 +08:00
parent 6a43f33f7a
commit 7a62d8962a
4 changed files with 16 additions and 32 deletions

View File

@@ -8,11 +8,15 @@ MYSQL_ROOT_PASSWORD=change-me-to-a-strong-password
DB_HOST=127.0.0.1
DB_PORT=3306
DB_USERNAME=root
DB_DATABASE=gongxue
DB_DATABASE=dorm_billing_v2
DB_SYNCHRONIZE=false
JWT_SECRET=change-me-to-a-random-string-at-least-32-chars
JWT_EXPIRES_IN=24h
PORT=3000
# 初始管理员 admin 密码(仅首次创建 admin 用户时生效)
ADMIN_PASSWORD=change-me-admin-password
PORT=3002
# ---- AI 模型配置 ----
# AES-256-GCM 加密主密钥,用于加密存储 API Key

View File

@@ -22,7 +22,7 @@ JWT_EXPIRES_IN=24h
ADMIN_PASSWORD=请替换为强密码
# ---- 服务端口 ----
PORT=3000
PORT=3002
# ---- 文件上传 ----
# 合同 PDF 存储根目录(相对或绝对)

View File

@@ -7,13 +7,14 @@ services:
restart: always
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-gongxue_2024}
MYSQL_DATABASE: gongxue
MYSQL_DATABASE: dorm_billing_v2
MYSQL_CHARSET: utf8mb4
MYSQL_COLLATION: utf8mb4_unicode_ci
ports:
- "127.0.0.1:3306:3306"
volumes:
- mysql_data:/var/lib/mysql
- ./docker/mysql/init.sql:/docker-entrypoint-initdb.d/01-init.sql:ro
command: --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
@@ -32,8 +33,8 @@ services:
DB_PORT: 3306
DB_USERNAME: root
DB_PASSWORD: ${MYSQL_ROOT_PASSWORD:-gongxue_2024}
DB_DATABASE: gongxue
DB_SYNCHRONIZE: "true"
DB_DATABASE: dorm_billing_v2
DB_SYNCHRONIZE: "false"
JWT_SECRET: ${JWT_SECRET:-gongxue-jwt-prod-2026-k3y}
JWT_EXPIRES_IN: 24h
PORT: 3000

View File

@@ -1,10 +1,10 @@
// PM2 进程配置 — 恭学教育
// 用法: pm2 start ecosystem.config.cjs
// 前提: 项目部署在 /opt/gongxuedeploy.sh 默认路径)
// .env 文件在 /opt/gongxue/.env
// docker compose up -d 已启动 MySQL
// 用法: pm2 startOrReload ecosystem.config.cjs --update-env
// 前提: 项目根目录执行;也可通过 DEPLOY_DIR 指定项目目录
// 生产环境配置写在项目根目录 .env由 Nest ConfigModule 读取
// 前端构建产物 apps/admin/dist 交给 Nginx 托管,不再用 PM2 启动前端
const DEPLOY_DIR = process.env.DEPLOY_DIR || '/opt/gongxue';
const DEPLOY_DIR = process.env.DEPLOY_DIR || __dirname;
module.exports = {
apps: [
@@ -16,19 +16,6 @@ module.exports = {
exec_mode: 'fork',
env: {
NODE_ENV: 'production',
PORT: '3000',
DB_TYPE: 'mysql',
DB_HOST: '127.0.0.1',
DB_PORT: '3306',
DB_USERNAME: 'root',
DB_PASSWORD: 'gongxue_2024',
DB_DATABASE: 'gongxue',
DB_SYNCHRONIZE: 'true',
JWT_SECRET: 'gongxue-jwt-prod-2026-k3y',
JWT_EXPIRES_IN: '24h',
UPLOAD_DIR: './uploads',
DINGTALK_APP_KEY: 'dingvpcg2i6p25ftxw5c',
DINGTALK_APP_SECRET: 'ovAEql1r5Lu9FvBve6bHwBZxXAZuEQwSNpG3DkRJk4DMhQwJ_raKDQc6emdlJisU',
},
// 内存限制
max_memory_restart: '512M',
@@ -41,13 +28,5 @@ module.exports = {
autorestart: true,
watch: false,
},
{
name: 'gongxue-frontend',
cwd: DEPLOY_DIR,
script: 'serve-proxy.js',
env: {
NODE_ENV: 'production',
},
},
],
};