From 5d11297d2368760e77a5494008b0a821ae507b97 Mon Sep 17 00:00:00 2001
From: xyc <jc_xiong@hotmail.com>
Date: 星期一, 05 十月 2026 06:54:23 +0800
Subject: [PATCH] fix(deploy): -NoFrontendDist 保留 backend/web,单端口瘦包改用 -SkipServiceWrapper
---
pack-deploy.ps1 | 22 +++++++++++++++++-----
1 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/pack-deploy.ps1 b/pack-deploy.ps1
index 71de807..c0bd2cb 100644
--- a/pack-deploy.ps1
+++ b/pack-deploy.ps1
@@ -3,13 +3,16 @@
鐢ㄦ硶锛�
powershell -NoProfile -ExecutionPolicy Bypass -File pack-deploy.ps1
powershell -NoProfile -ExecutionPolicy Bypass -File pack-deploy.ps1 -OutRoot "E:\璇曢獙" -SkipFrontend
+ powershell -NoProfile -ExecutionPolicy Bypass -File pack-deploy.ps1 -NoFrontendDist -SkipServiceWrapper
+ 鈥斺�� 鍗曠鍙e彂甯冿細涓嶇敓鎴愮嫭绔嬬殑 frontend\dist 鐩綍锛堜粛鏋勫缓骞跺悓姝� backend\web锛屽崟绔彛蹇呴渶锛夛紱
+ 鏈嶅姟鍣ㄥ凡瑁呮湇鍔℃椂閰嶅悎 -SkipServiceWrapper 鍘绘帀绾� 17 MB 鐨� WinSW锛屽彲鏄捐憲鍑忓皬鍖呬綋绉��
鍋氫簲浠朵簨锛�
1) 鐢� deploy-templates\jar-application.yml锛堝叏鍗犱綅绗︼級涓存椂鏇挎崲婧愮爜 application.yml锛�
鎵ц mvn clean package锛涙棤璁烘垚璐ラ兘杩樺師寮�鍙戞満鐪熷疄閰嶇疆
2) 瑙e帇 jar 妫�鏌ュ唴缃� application.yml锛氬繀椤诲叏鏄崰浣嶇锛堢姝� sk- 瀵嗛挜 / 鏄庢枃鍙d护锛夛紝涓嶅悎鏍肩洿鎺ヤ腑姝�
3) npm run build 閲嶅缓鍓嶇 dist锛堝彲 -SkipFrontend锛�
- 4) 缁勮瀹屾暣閮ㄧ讲鍖咃細backend(jar + application.yml + 鍚姩鑴氭湰 + 鏈嶅姟鍖呰鍣� + docs + web) / frontend/dist / db / README
+ 4) 缁勮瀹屾暣閮ㄧ讲鍖咃細backend(jar + application.yml + 鍚姩鑴氭湰 + 鏈嶅姟鍖呰鍣� + docs + web) / frontend/dist(鍙�夛紝-NoFrontendDist 涓嶆墦) / db / README
Windows 鏈嶅姟鍖呰鍣� WinSW锛氫紭鍏堢敤 deploy-templates\tools\winsw.exe 缂撳瓨锛堟牎楠� SHA-256锛夛紝
缂哄け鏃惰嚜鍔ㄤ笅杞� v2.12.0 x64 鍒拌缂撳瓨鐩綍锛涢殢鍖呰緭鍑轰负 backend\trafficAudit.exe
5) 瀵圭粍瑁呭悗鐨勬暣鍖呭啀鎵竴閬嶆槑鏂囧瘑閽�
@@ -22,6 +25,7 @@
param(
[string]$OutRoot = '',
[switch]$SkipFrontend,
+ [switch]$NoFrontendDist, # 鍗曠鍙e彂甯冿細涓嶆墦鐙珛鐨� frontend\dist 鐩綍锛屼絾浠嶆瀯寤�/鍚屾 backend\web锛堝崟绔彛蹇呴渶锛�
[switch]$SkipBackend, # 澶嶇敤宸插瓨鍦ㄧ殑 jar锛堜笉閲嶇紪璇戙�佷笉鍔ㄦ簮鐮侀厤缃級锛屼粎鐢ㄤ簬琛ュ叏/閲嶇粍鍙戝竷鍖�
[switch]$SkipServiceWrapper # 涓嶆妸 WinSW 鏈嶅姟鍖呰鍣ㄦ墦杩涘寘锛堝嵆涓嶆彁渚涒�滄敞鍐屾垚 Windows 鏈嶅姟鈥濈殑寮�鏈鸿嚜鍚級
)
@@ -106,6 +110,7 @@
Write-Host ' 閫氳繃锛歫ar 鍐呯疆閰嶇疆鍏ㄩ儴涓哄崰浣嶇锛屾棤鏄庢枃瀵嗛挜/鍙d护銆�'
# ---------- [3/5] 鍓嶇鏋勫缓 ----------
+# 鍗曠鍙i儴缃插繀椤绘湁 backend\web锛屾墍浠ュ嵆浣� -NoFrontendDist 涔熼渶瑕� dist锛涘彧鏈� -SkipFrontend 鎵嶅鐢ㄧ幇鏈� dist銆�
Write-Host '[3/5] 鏋勫缓鍓嶇锛坣pm run build锛屽彲 -SkipFrontend 璺宠繃锛�...'
if (-not $SkipFrontend) {
Push-Location (Join-Path $root 'traffic-audit-web')
@@ -160,7 +165,11 @@
$dest = Join-Path $OutRoot ("traffic-audit-deploy-" + $stamp)
$n = 2
while (Test-Path $dest) { $dest = Join-Path $OutRoot ("traffic-audit-deploy-" + $stamp + "-" + $n); $n++ }
-New-Item -ItemType Directory -Force -Path (Join-Path $dest 'backend'), (Join-Path $dest 'frontend'), (Join-Path $dest 'db') | Out-Null
+if ($NoFrontendDist) {
+ New-Item -ItemType Directory -Force -Path (Join-Path $dest 'backend'), (Join-Path $dest 'db') | Out-Null
+} else {
+ New-Item -ItemType Directory -Force -Path (Join-Path $dest 'backend'), (Join-Path $dest 'frontend'), (Join-Path $dest 'db') | Out-Null
+}
Copy-Item $jar (Join-Path $dest 'backend') -Force
Copy-Item (Join-Path $tplDir 'backend\application.yml') (Join-Path $dest 'backend') -Force
@@ -175,11 +184,14 @@
Copy-Item (Join-Path $tplDir 'backend\install-service.ps1') (Join-Path $dest 'backend') -Force
Copy-Item (Join-Path $tplDir 'backend\install-service.cmd') (Join-Path $dest 'backend') -Force
}
-Copy-Item $webDist (Join-Path $dest 'frontend') -Recurse -Force
-Copy-Item (Join-Path $tplDir 'frontend\nginx.conf.example') (Join-Path $dest 'frontend') -Force
+if (-not $NoFrontendDist) {
+ Copy-Item $webDist (Join-Path $dest 'frontend') -Recurse -Force
+ Copy-Item (Join-Path $tplDir 'frontend\nginx.conf.example') (Join-Path $dest 'frontend') -Force
+}
Copy-Item (Join-Path $tplDir 'db\*.sql') (Join-Path $dest 'db') -Force
-# 鍗曠鍙� 8090 妯″紡锛氬悗绔粠 jar 鍚岀骇 web\ 璇诲墠绔潤鎬佹枃浠讹紝蹇呴』鍜� dist 鍐呭涓�鑷�
+# 鍗曠鍙� 8090 妯″紡锛氬悗绔粠 jar 鍚岀骇 web\ 璇诲墠绔潤鎬佹枃浠讹紝蹇呴』鍜� dist 鍐呭涓�鑷淬��
+# 鍗曠鍙e彂甯冿紙-NoFrontendDist锛夊悓鏍峰繀椤诲悓姝ワ紝鍚﹀垯椤甸潰 404銆�
Copy-Item $webDist (Join-Path $dest 'backend\web') -Recurse -Force
# docs锛氳繍琛屾椂妯℃澘 + 鐢ㄦ埛鏂囨。锛涙帓闄ゅ紑鍙戣繃绋嬫枃妗d笌缂撳瓨/澶囦唤锛堝噺灏忎綋绉�侀伩鍏嶆妸鍐呴儴娓呭崟甯﹀嚭鍘伙級
--
Gitblit v1.9.1