feat: 新增模板文件
This commit is contained in:
parent
b3ebaa767f
commit
cc263193d0
|
|
@ -583,6 +583,7 @@ function main() {
|
|||
console.error(`\u274C \u4E0D\u652F\u6301\u7684\u6784\u5EFA\u7C7B\u578B: ${options.buildType}`);
|
||||
process.exit(1);
|
||||
}
|
||||
copyTemplateFiles(path3.join(pwd2, "dist"));
|
||||
}
|
||||
function packageBackend(projectDir, options) {
|
||||
const imageBase = path3.basename(projectDir);
|
||||
|
|
@ -667,4 +668,26 @@ function packageInit(projectDir, options) {
|
|||
fs3.rmSync(path3.join(pwd, ".dockerignore"), { force: true });
|
||||
}
|
||||
}
|
||||
function copyTemplateFiles(dist) {
|
||||
const templateDir = path3.join(__dirname, "../template");
|
||||
function copyDir(srcDir, destDir) {
|
||||
if (!fs3.existsSync(destDir)) {
|
||||
fs3.mkdirSync(destDir, { recursive: true });
|
||||
}
|
||||
const entries = fs3.readdirSync(srcDir, { withFileTypes: true });
|
||||
for (const entry of entries) {
|
||||
const srcPath = path3.join(srcDir, entry.name);
|
||||
const destPath = path3.join(destDir, entry.name);
|
||||
if (entry.isDirectory()) {
|
||||
copyDir(srcPath, destPath);
|
||||
} else {
|
||||
if (fs3.existsSync(destPath)) {
|
||||
continue;
|
||||
}
|
||||
fs3.copyFileSync(srcPath, destPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
copyDir(templateDir, dist);
|
||||
}
|
||||
main();
|
||||
|
|
|
|||
30
src/cli.ts
30
src/cli.ts
|
|
@ -271,6 +271,8 @@ function main(): void {
|
|||
console.error(`❌ 不支持的构建类型: ${options.buildType}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
copyTemplateFiles(path.join(pwd, "dist"));
|
||||
}
|
||||
|
||||
function packageBackend(projectDir: string, options: BuildOptions): void {
|
||||
|
|
@ -411,5 +413,33 @@ function packageInit(projectDir: string, options: BuildOptions): void {
|
|||
}
|
||||
}
|
||||
|
||||
function copyTemplateFiles(
|
||||
dist: string,
|
||||
) {
|
||||
const templateDir = path.join(__dirname, "../template");
|
||||
// 递归复制 template 目录下的所有文件到 dist 目录
|
||||
function copyDir(srcDir: string, destDir: string) {
|
||||
if (!fs.existsSync(destDir)) {
|
||||
fs.mkdirSync(destDir, { recursive: true });
|
||||
}
|
||||
const entries = fs.readdirSync(srcDir, { withFileTypes: true });
|
||||
for (const entry of entries) {
|
||||
const srcPath = path.join(srcDir, entry.name);
|
||||
const destPath = path.join(destDir, entry.name);
|
||||
if (entry.isDirectory()) {
|
||||
copyDir(srcPath, destPath);
|
||||
} else {
|
||||
// 如果文件存在就跳过
|
||||
if (fs.existsSync(destPath)) {
|
||||
continue;
|
||||
}
|
||||
fs.copyFileSync(srcPath, destPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
copyDir(templateDir, dist);
|
||||
}
|
||||
|
||||
// 执行主函数
|
||||
main();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,68 @@
|
|||
version: '3.8'
|
||||
|
||||
services:
|
||||
# =======================
|
||||
# MySQL 数据库
|
||||
# =======================
|
||||
mysql:
|
||||
image: mysql:8.2
|
||||
container_name: mysql_container
|
||||
restart: always
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: your_root_password
|
||||
MYSQL_DATABASE: your_database
|
||||
MYSQL_USER: your_user
|
||||
MYSQL_PASSWORD: your_password
|
||||
network_mode: host
|
||||
volumes:
|
||||
- mysql_data:/var/lib/mysql
|
||||
|
||||
# =======================
|
||||
# Redis 缓存
|
||||
# =======================
|
||||
redis:
|
||||
image: redis:7.2
|
||||
container_name: redis_container
|
||||
restart: always
|
||||
network_mode: host
|
||||
volumes:
|
||||
- redis_data:/data
|
||||
|
||||
# =======================
|
||||
# MinIO 对象存储
|
||||
# =======================
|
||||
minio:
|
||||
image: minio/minio:latest
|
||||
container_name: minio_container
|
||||
restart: always
|
||||
environment:
|
||||
MINIO_ROOT_USER: minioadmin
|
||||
MINIO_ROOT_PASSWORD: minioadmin
|
||||
command: server /data --console-address ":9001"
|
||||
network_mode: host
|
||||
volumes:
|
||||
- minio_data:/data
|
||||
|
||||
# =======================
|
||||
# Nginx 网关
|
||||
# =======================
|
||||
nginx:
|
||||
image: nginx:latest
|
||||
container_name: nginx_container
|
||||
restart: always
|
||||
network_mode: host
|
||||
volumes:
|
||||
- ./conf.d:/etc/nginx/conf.d:ro
|
||||
- ./html:/usr/share/nginx/html:ro
|
||||
depends_on:
|
||||
- mysql
|
||||
- redis
|
||||
- minio
|
||||
|
||||
# =======================
|
||||
# 数据卷
|
||||
# =======================
|
||||
volumes:
|
||||
mysql_data:
|
||||
redis_data:
|
||||
minio_data:
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
|
||||
# WebSocket support
|
||||
map $http_upgrade $connection_upgrade {
|
||||
default upgrade;
|
||||
'' close;
|
||||
}
|
||||
|
||||
|
||||
server {
|
||||
listen 3021;
|
||||
server_name 192.168.34.21;
|
||||
index index.html index.htm index.jsp;
|
||||
root /usr/share/nginx/html/haina-cn/web;
|
||||
|
||||
gzip on;
|
||||
gzip_min_length 1k;
|
||||
gzip_comp_level 2;
|
||||
gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php;
|
||||
gzip_vary on;
|
||||
gzip_disable "MSIE [1-6]\.";
|
||||
|
||||
|
||||
location ~ ^/oak-api/.*$ {
|
||||
# First attempt to serve request as file, then
|
||||
# as directory, then fall back to displaying a 404.
|
||||
#try_files $uri /index.html;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
rewrite /oak-api/(.*) /$1 break;
|
||||
proxy_read_timeout 1500;
|
||||
proxy_connect_timeout 1500;
|
||||
proxy_send_timeout 1500;
|
||||
send_timeout 1500;
|
||||
client_max_body_size 10m;
|
||||
proxy_pass http://192.168.34.21:3011;
|
||||
}
|
||||
|
||||
location ~ ^/oak-skt/.*$ {
|
||||
# First attempt to serve request as file, then
|
||||
# as directory, then fall back to displaying a 404.
|
||||
#try_files $uri /index.html;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
rewrite /oak-skt/(.*) /$1 break;
|
||||
proxy_read_timeout 1500;
|
||||
proxy_connect_timeout 1500;
|
||||
proxy_send_timeout 1500;
|
||||
send_timeout 1500;
|
||||
client_max_body_size 10m;
|
||||
proxy_pass http://192.168.34.21:8080;
|
||||
}
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
error_page 404 /404.html;
|
||||
location = /40x.html {
|
||||
}
|
||||
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue