diff --git a/README.en.md b/README.en.md index b82a08211..fc2b8b3ae 100644 --- a/README.en.md +++ b/README.en.md @@ -293,11 +293,11 @@ yarn run build:prod ### About Docker container -**Step 1**: build the background service, recommend running the batch file directly, parameters of the publish, the content, can see the batch **pay attention to the configuration file, after the release of service requires appsettings.Production.json** +**Step 1**: Building background services, powershell script: **./build/build-aspnetcore-release.ps1**, **Warning: after the release of service need configuration file: appsettings.Production.json** -**Step 2**: Build the front-end, yarn/npm build:PROD +**Step 2**: Build the front-end, **./build/build-vue-element-admin.ps1** -**Step 3**: Change nginx proxy server address, ./vueJs/docker/nginx/default.conf +**Step 3**: Build after the release of the address of the default in **./aspnet-core/services/Publish**, change nginx proxy server address: **./client/docker/nginx/default.conf** **Step 4**: Run command **sudo docker-compose down && sudo docker-compose -f docker-compose.yml -f docker-compose.override.yml up --build -d** diff --git a/README.md b/README.md index 053ab6ca9..480a69186 100644 --- a/README.md +++ b/README.md @@ -296,11 +296,11 @@ yarn build:prod ### 关于docker容器部署 -**第一步**: 构建后台服务,推荐直接运行批处理文件,参数为 --publish,具体可参见批处理内容,**注意配置文件,发布后的服务需要 appsettings.Production.json 文件** +**第一步**: 构建后台服务, powershell脚本:**./build/build-aspnetcore-release.ps1**, **注意:发布后的服务需要 appsettings.Production.json 文件** -**第二步**: 构建前端, yarn/npm build:prod +**第二步**: 构建前端, **./build/build-vue-element-admin.ps1** -**第三步**: 变更nginx代理服务器地址, ./vueJs/docker/nginx/default.conf +**第三步**: 构建后的发布地址默认在**cd ./aspnet-core/services/Publish** ,变更nginx代理服务器地址: **./client/docker/nginx/default.conf** **第四步**: 运行此命令 **sudo docker-compose down && sudo docker-compose -f docker-compose.yml -f docker-compose.override.yml up --build -d** diff --git a/aspnet-core/services/start-apigateway-admin.bat b/aspnet-core/services/start-apigateway-admin.bat index e7f90a566..3fa1fcf96 100644 --- a/aspnet-core/services/start-apigateway-admin.bat +++ b/aspnet-core/services/start-apigateway-admin.bat @@ -6,6 +6,7 @@ echo. 启动网关管理服务 cd .\apigateway\LINGYUN.ApiGateway.HttpApi.Host +echo %1 if '%1' equ '--publish' goto publish if '%1' equ '--run' goto run if '%1' equ '--restore' goto restore @@ -15,15 +16,12 @@ if '%1' equ '' goto run :publish dotnet publish -c Release -o ..\..\Publish\apigateway-admin --no-cache --no-restore copy Dockerfile ..\..\Publish\apigateway-admin \Dockerfile -pause exit :run dotnet run -pause exit :restore dotnet restore -pause exit \ No newline at end of file diff --git a/aspnet-core/services/start-apigateway-host.bat b/aspnet-core/services/start-apigateway-host.bat index c2548aaff..7eaa23a70 100644 --- a/aspnet-core/services/start-apigateway-host.bat +++ b/aspnet-core/services/start-apigateway-host.bat @@ -14,15 +14,12 @@ if '%1' equ '' goto run :publish dotnet publish -c Release -o ..\..\Publish\apigateway-host --no-cache --no-restore copy Dockerfile ..\..\Publish\apigateway-host\Dockerfile -pause exit :run dotnet run -pause exit :restore dotnet restore -pause exit \ No newline at end of file diff --git a/aspnet-core/services/start-backend-admin.bat b/aspnet-core/services/start-backend-admin.bat index c18e6ed0a..2da54a63e 100644 --- a/aspnet-core/services/start-backend-admin.bat +++ b/aspnet-core/services/start-backend-admin.bat @@ -15,15 +15,12 @@ exit :publish dotnet publish -c Release -o ..\..\Publish\admin --no-cache --no-restore copy Dockerfile ..\..\Publish\admin\Dockerfile -pause exit :run dotnet run -pause exit :restore dotnet restore -pause exit \ No newline at end of file diff --git a/aspnet-core/services/start-identity-server.bat b/aspnet-core/services/start-identity-server.bat index b44896b8b..25ed0a9c0 100644 --- a/aspnet-core/services/start-identity-server.bat +++ b/aspnet-core/services/start-identity-server.bat @@ -14,16 +14,13 @@ exit :publish dotnet publish -c Release -o ..\..\Publish\identityserver --no-cache --no-restore -copy Dockerfile ..\..\Publish\account\Dockerfile -pause +copy Dockerfile ..\..\Publish\identityserver\Dockerfile exit :run dotnet run -pause exit :restore dotnet restore -pause exit \ No newline at end of file diff --git a/aspnet-core/services/start-messages.bat b/aspnet-core/services/start-messages.bat index 42b2fae8d..40bd48840 100644 --- a/aspnet-core/services/start-messages.bat +++ b/aspnet-core/services/start-messages.bat @@ -15,15 +15,12 @@ exit :publish dotnet publish -c Release -o ..\..\Publish\messages --no-cache --no-restore copy Dockerfile ..\..\Publish\messages\Dockerfile -pause exit :run dotnet run -pause exit :restore dotnet restore -pause exit \ No newline at end of file diff --git a/aspnet-core/services/start-platform.bat b/aspnet-core/services/start-platform.bat index ec53ba334..0a8436521 100644 --- a/aspnet-core/services/start-platform.bat +++ b/aspnet-core/services/start-platform.bat @@ -15,15 +15,12 @@ exit :publish dotnet publish -c Release -o ..\..\Publish\platform --no-cache --no-restore copy Dockerfile ..\..\Publish\platform\Dockerfile -pause exit :run dotnet run -pause exit :restore dotnet restore -pause exit \ No newline at end of file diff --git a/build/build-aspnetcore-common.ps1 b/build/build-aspnetcore-common.ps1 new file mode 100644 index 000000000..a9ba75bc2 --- /dev/null +++ b/build/build-aspnetcore-common.ps1 @@ -0,0 +1,17 @@ +# COMMON PATHS + +$rootFolder = (Get-Item -Path "./" -Verbose).FullName + +# List of solutions used only in development mode +$batchCommandPaths = @( + "../aspnet-core/services/start-identity-server.bat", + "../aspnet-core/services/start-backend-admin.bat", + "../aspnet-core/services/start-apigateway-host.bat", + "../aspnet-core/services/start-apigateway-admin.bat", + "../aspnet-core/services/start-messages.bat", + "../aspnet-core/services/start-platform.bat" + ) + +Write-host "" +Write-host ":::::::::::::: !!! You are in development mode !!! ::::::::::::::" -ForegroundColor red -BackgroundColor yellow +Write-host "" \ No newline at end of file diff --git a/build/build-aspnetcore-release.ps1 b/build/build-aspnetcore-release.ps1 new file mode 100644 index 000000000..f5a1f37df --- /dev/null +++ b/build/build-aspnetcore-release.ps1 @@ -0,0 +1,11 @@ +. "./build-aspnetcore-common.ps1" + +# Build all solutions +foreach ($batchCommandPath in $batchCommandPaths) { + $file = [io.fileinfo]$batchCommandPath; + Write-Host $file.DirectoryName + Set-Location $file.DirectoryName + CMD /c $file.Name --publish -Wait +} + +Set-Location $rootFolder \ No newline at end of file diff --git a/build/build-vue-element-admin.ps1 b/build/build-vue-element-admin.ps1 new file mode 100644 index 000000000..494395949 --- /dev/null +++ b/build/build-vue-element-admin.ps1 @@ -0,0 +1,20 @@ +$rootFolder = (Get-Item -Path "./" -Verbose).FullName + +$vuePath = Join-Path $rootFolder "../vueJs" + +$publishPath = Join-Path $rootFolder "../aspnet-core/services/Publish/client" +$distPath = Join-Path $rootFolder "../aspnet-core/services/Publish/client/dist" +$dockerPath = Join-Path $rootFolder "../aspnet-core/services/Publish/client/docker" +Set-Location $vuePath + +Remove-Item (Join-Path $vuePath "dist") -Recurse +Remove-Item $publishPath -Recurse + +CMD /c npm install +CMD /c npm run build:prod + +Copy-Item -Path (Join-Path $vuePath "dist") -Destination $distPath -Recurse +Copy-Item -Path (Join-Path $vuePath "docker") -Destination $dockerPath -Recurse +Copy-Item (Join-Path $vuePath "Dockerfile") -Destination $publishPath + +Set-Location $rootFolder \ No newline at end of file