88 lines
2.4 KiB
Markdown
88 lines
2.4 KiB
Markdown
# 脚本说明
|
||
|
||
## 核心部署脚本
|
||
|
||
### `deploy-git-build.ps1` ⭐
|
||
**主部署脚本** - Git 工作流部署(推荐使用)
|
||
- 本地提交代码到 Git
|
||
- 服务器从 Git 拉取代码
|
||
- 服务器端构建 Docker 镜像
|
||
- 自动部署新容器
|
||
- 支持清理旧镜像(保留最新4个)
|
||
|
||
**重要提示:**
|
||
- ⚠️ **文件位置**:此脚本位于**项目根目录**(`d:\gongxiangp2\deploy-git-build.ps1`),**不在** `scripts` 目录
|
||
- ⚠️ **部署流程**:本地提交 → Git推送 → 服务器拉取 → 服务器构建 → 部署
|
||
|
||
**使用方式:**
|
||
```powershell
|
||
# 在项目根目录执行(d:\gongxiangp2\)
|
||
# 部署到正式系统(端口 4320,自动提交并推送代码)
|
||
.\deploy-git-build.ps1 -Target production
|
||
|
||
# 部署到影子系统(端口 5320)
|
||
.\deploy-git-build.ps1 -Target shadow
|
||
|
||
# 指定提交信息
|
||
.\deploy-git-build.ps1 -Target production -CommitMessage "修复BUG"
|
||
|
||
# 仅提交不推送(用于本地测试)
|
||
.\deploy-git-build.ps1 -Target shadow -SkipPush
|
||
|
||
# 跳过提交,直接推送已有提交
|
||
.\deploy-git-build.ps1 -Target production -SkipCommit
|
||
|
||
# 构建镜像时禁用缓存
|
||
.\deploy-git-build.ps1 -Target production -NoCache
|
||
|
||
# 跳过构建产物清理
|
||
.\deploy-git-build.ps1 -Target production -SkipCleanup
|
||
|
||
# 显示帮助
|
||
.\deploy-git-build.ps1 -Help
|
||
```
|
||
|
||
**参数说明:**
|
||
- `-Target`: 部署目标,`shadow`(影子系统,端口5320)或 `production`(正式系统,端口4320)
|
||
- `-CommitMessage`: 提交信息(如果为空,将自动生成)
|
||
- `-SkipCommit`: 跳过Git提交(直接推送到远程)
|
||
- `-SkipPush`: 跳过Git推送(仅提交,不推送)
|
||
- `-NoCache`: 构建镜像时禁用缓存
|
||
- `-SkipCleanup`: 跳过构建产物清理
|
||
|
||
## 基础镜像管理
|
||
|
||
### `save-base-images.ps1`
|
||
下载并保存基础镜像到本地缓存
|
||
```powershell
|
||
.\save-base-images.ps1
|
||
```
|
||
|
||
### `load-base-images.ps1`
|
||
从本地加载基础镜像(部署脚本会自动调用)
|
||
```powershell
|
||
.\load-base-images.ps1
|
||
```
|
||
|
||
### `save-npm-packages.ps1`(可选)
|
||
缓存 npm 包到本地(网络不稳定时使用)
|
||
```powershell
|
||
.\save-npm-packages.ps1
|
||
```
|
||
|
||
## 数据库迁移脚本
|
||
|
||
### `execute-migration.ps1`
|
||
在生产库上执行数据库迁移(Windows PowerShell)
|
||
```powershell
|
||
.\execute-migration.ps1
|
||
```
|
||
|
||
### `execute-migration.sh`
|
||
在生产库上执行数据库迁移(Linux/Mac)
|
||
```bash
|
||
chmod +x execute-migration.sh
|
||
./execute-migration.sh
|
||
```
|
||
|