refactor: build on production updated

This commit is contained in:
louis 2024-03-28 12:48:22 +08:00
parent c9437d7c67
commit 8b445f9925
9 changed files with 1198 additions and 950 deletions

5
.env
View File

@ -1,9 +1,12 @@
# app # app
APP_NAME = Huaxin OA APP_NAME = Huaxin OA
APP_PORT = 7001 APP_PORT = 8001
APP_BASE_URL = http://localhost:${APP_PORT} APP_BASE_URL = http://localhost:${APP_PORT}
APP_LOCALE = zh-CN APP_LOCALE = zh-CN
# cluster
CPU_LEN = 1
# logger # logger
LOGGER_LEVEL = verbose LOGGER_LEVEL = verbose
LOGGER_MAX_FILES = 31 LOGGER_MAX_FILES = 31

View File

@ -6,7 +6,7 @@ FROM node:20-slim AS base
ENV PROJECT_DIR=/huaxin-admin \ ENV PROJECT_DIR=/huaxin-admin \
DB_HOST=mysql \ DB_HOST=mysql \
APP_PORT=7001 \ APP_PORT=8001 \
PNPM_HOME="/pnpm" \ PNPM_HOME="/pnpm" \
PATH="$PNPM_HOME:$PATH" PATH="$PNPM_HOME:$PATH"

View File

@ -97,7 +97,7 @@ pnpm migration:revert
4.执行sql覆盖docker中的数据库 4.执行sql覆盖docker中的数据库
```bash ```bash
docker exec -i huaxin-admin-mysql mysql -h 127.0.0.1 -u root -phuaxin123 hxoa < hxoa_2024-03-07_171919.sql docker exec -i huaxin-admin-mysql mysql -h 127.0.0.1 -u root -phuaxin123 hxoa < huaxinoa0327.sql
``` ```
更多细节,请移步至[官方文档](https://typeorm.io/migrations) 更多细节,请移步至[官方文档](https://typeorm.io/migrations)

View File

@ -1,6 +1,9 @@
#!/bin/bash #!/bin/bash
# 拉取最新的代码 # 拉取最新的代码
git config core.fileMode false
git pull git pull
docker compose --env-file .env --env-file .env.production up -d --build docker-compose --env-file .env --env-file .env.production up -d --build

File diff suppressed because one or more lines are too long

View File

@ -2,7 +2,7 @@ version: '3'
services: services:
mysql: mysql:
image: mysql:latest image: mysql:8.0
container_name: huaxin-admin-mysql container_name: huaxin-admin-mysql
restart: always restart: always
env_file: env_file:
@ -17,10 +17,11 @@ services:
- MYSQL_ROOT_PASSWORD=${DB_PASSWORD} - MYSQL_ROOT_PASSWORD=${DB_PASSWORD}
ports: ports:
- '${DB_PORT}:3306' - '${DB_PORT}:3306'
command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci #设置utf8字符集 command:
mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci
volumes: volumes:
- ./__data/mysql/:/var/lib/mysql/ # ./__data/mysql/ 路径可以替换成自己的路径 - ./__data/mysql/:/var/lib/mysql/ # ./__data/mysql/ 路径可以替换成自己的路径
- ./deploy/sql/:/docker-entrypoint-initdb.d/ # 初始化的脚本,若 ./__data/mysql/ 文件夹存在数据,则不会执行初始化脚本 - ./init_data/sql/:/docker-entrypoint-initdb.d/ # 初始化的脚本,若 ./__data/mysql/ 文件夹存在数据,则不会执行初始化脚本
networks: networks:
- huaxin_admin_net - huaxin_admin_net

View File

@ -1,6 +1,6 @@
const { cpus } = require('os') const { cpus } = require('os');
const cpuLen = cpus().length const cpuLen = cpus().length;
module.exports = { module.exports = {
apps: [ apps: [
@ -10,13 +10,13 @@ module.exports = {
autorestart: true, autorestart: true,
exec_mode: 'cluster', exec_mode: 'cluster',
watch: false, watch: false,
instances: cpuLen, instances: process.env.CPU_LEN ?? cpuLen,
max_memory_restart: '520M', max_memory_restart: '520M',
args: '', args: '',
env: { env: {
NODE_ENV: 'production', NODE_ENV: 'production',
PORT: process.env.APP_PORT, PORT: process.env.APP_PORT
}, }
}, }
], ]
} };

1175
init_data/sql/hxoa.sql Normal file

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@ import path from 'node:path';
import { MigrationInterface, QueryRunner } from 'typeorm'; import { MigrationInterface, QueryRunner } from 'typeorm';
const sql = fs.readFileSync(path.join(__dirname, '../../deploy/sql/hxoa.sql'), 'utf8'); const sql = fs.readFileSync(path.join(__dirname, '../../init_data/sql/hxoa.sql'), 'utf8');
export class InitData1707996695540 implements MigrationInterface { export class InitData1707996695540 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> { public async up(queryRunner: QueryRunner): Promise<void> {