-
Notifications
You must be signed in to change notification settings - Fork 278
/
Copy pathdeploy.ps1
59 lines (49 loc) · 1.68 KB
/
deploy.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
. "../build/build-aspnetcore-common.ps1"
Write-host "开始部署容器."
$rootFolder = (Get-Item -Path "../" -Verbose).FullName
$deployPath = $rootFolder + "/deploy";
$buildPath = $rootFolder + "/build";
$aspnetcorePath = $rootFolder + "/aspnet-core";
$vuePath = $rootFolder + "/apps/vue";
Write-host "root: " + $rootFolder
## 部署中间件
Write-host "deploy middleware..."
Set-Location $rootFolder
docker-compose -f .\docker-compose.middleware.yml up -d --build
## 等待30秒, 数据库初始化完成
Write-host "initial database..."
Start-Sleep -Seconds 30
## 创建数据库
Write-host "create database..."
Set-Location $aspnetcorePath
cmd.exe /c create-database.bat
## 执行数据库迁移
Start-Sleep -Seconds 5
Write-host "migrate database..."
Set-Location $buildPath
foreach ($solution in $migrationArray) {
Set-Location $solution.Path
dotnet run --no-build
}
## 发布程序包
Write-host "release .net project..."
Set-Location $buildPath
foreach ($solution in $serviceArray) {
$publishPath = $rootFolder + "/aspnet-core/services/Publish/" + $solution.Service + "/"
dotnet publish -c Release -o $publishPath $solution.Path --no-cache
$dockerFile = Join-Path $solution.Path "Dockerfile"
if ((Test-Path $dockerFile)) {
Copy-Item $dockerFile -Destination $publishPath
}
}
## 构建前端项目
Write-host "build front project..."
Set-Location $vuePath
pnpm install
pnpm build
## 运行应用程序
Write-host "running application..."
Set-Location $rootFolder
docker-compose -f .\docker-compose.yml -f .\docker-compose.override.yml -f .\docker-compose.override.configuration.yml up -d --build
Set-Location $deployPath
Write-host "application is running..."