diff --git a/Volo.Abp.sln b/Volo.Abp.sln index 28aa91ae4d..54ec3561c6 100644 --- a/Volo.Abp.sln +++ b/Volo.Abp.sln @@ -76,6 +76,12 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "AbpDesk.MongoBlog", "src\Ab EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "AbpDesk.SamplePlugInModule", "src\AbpDesk\AbpDesk.SamplePlugInModule\AbpDesk.SamplePlugInModule.xproj", "{ADFAF85B-B785-41EA-B57D-422775989FA6}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docker-files", "docker-files", "{0BEA55D6-E0B8-40DD-A256-B34C4DD990A5}" + ProjectSection(SolutionItems) = preProject + docker\docker-compose.yml = docker\docker-compose.yml + docker\haproxy.cfg = docker\haproxy.cfg + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -223,5 +229,6 @@ Global {B31FFAE3-5DAC-4E51-BD17-F7446B741A36} = {4C753F64-0C93-4D65-96C2-A40893AFC1E8} {63244DC7-34BE-44E1-BF6F-F2672E59AF36} = {1187F469-0063-4065-9419-A1D956C80145} {ADFAF85B-B785-41EA-B57D-422775989FA6} = {1187F469-0063-4065-9419-A1D956C80145} + {0BEA55D6-E0B8-40DD-A256-B34C4DD990A5} = {CBCC288A-53C3-402F-99F7-E468738560F5} EndGlobalSection EndGlobal diff --git a/build/build.ps1 b/build/build.ps1 index 47309dec9c..c9425069ce 100644 --- a/build/build.ps1 +++ b/build/build.ps1 @@ -1,14 +1,30 @@ -$buildFolder = (Get-Item -Path ".\" -Verbose).FullName -$outputFolder = Join-Path $buildFolder "outputs" +# COMMON PATHS +$buildFolder = (Get-Item -Path ".\" -Verbose).FullName $slnFolder = Join-Path $buildFolder "..\" +$outputFolder = Join-Path $buildFolder "outputs" $abpDeskFolder = Join-Path $slnFolder "src/AbpDesk" $abpDeskWebFolder = Join-Path $abpDeskFolder "AbpDesk.Web.Mvc" +# BUILD + Set-Location $slnFolder dotnet restore +# PUBLISH + Set-Location $abpDeskWebFolder dotnet publish --output (Join-Path $outputFolder "AbpDesk/Web") -Set-Location $buildFolder +# CREATE DOCKER IMAGES + +Set-Location (Join-Path $outputFolder "AbpDesk/Web") + +docker rmi abpdesk/web -f +docker build -t abpdesk/web . + +Copy-Item (Join-Path $slnFolder "/docker/*.*") $outputFolder + +# FINALIZE + +Set-Location $outputFolder \ No newline at end of file diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 0000000000..a1d98519fd --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,21 @@ +version: '2' + +services: + abpdesk_web_1: + image: abpdesk/web + environment: + - ASPNETCORE_ENVIRONMENT=Staging + ports: + - "9001:80" + abpdesk_web_2: + image: abpdesk/web + environment: + - ASPNETCORE_ENVIRONMENT=Staging + ports: + - "9002:80" + load_balancer: + image: haproxy:1.7.1 + volumes: + - "./haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg" + ports: + - "9005:9005" \ No newline at end of file diff --git a/docker/haproxy.cfg b/docker/haproxy.cfg new file mode 100644 index 0000000000..43629caeb0 --- /dev/null +++ b/docker/haproxy.cfg @@ -0,0 +1,18 @@ +global + maxconn 4096 + +defaults + mode http + timeout connect 5s + timeout client 50s + timeout server 50s + +listen http-in + bind *:9005 + + server web-1 outputs_abpdesk_web_1_1:80 + server web-2 outputs_abpdesk_web_2_1:80 + + stats enable + stats uri /haproxy + stats refresh 1s \ No newline at end of file diff --git a/src/AbpDesk/AbpDesk.Web.Mvc/AbpDeskWebMvcModule.cs b/src/AbpDesk/AbpDesk.Web.Mvc/AbpDeskWebMvcModule.cs index 2d3aed2ea6..93b7306009 100644 --- a/src/AbpDesk/AbpDesk.Web.Mvc/AbpDeskWebMvcModule.cs +++ b/src/AbpDesk/AbpDesk.Web.Mvc/AbpDeskWebMvcModule.cs @@ -20,7 +20,7 @@ namespace AbpDesk.Web.Mvc public override void ConfigureServices(IServiceCollection services) { var hostingEnvironment = services.GetSingletonInstance(); - var configuration = BuildConfiguration(hostingEnvironment.ContentRootPath); + var configuration = BuildConfiguration(hostingEnvironment); AbpDeskDbConfigurer.Configure(services, configuration); @@ -49,11 +49,12 @@ namespace AbpDesk.Web.Mvc }); } - private static IConfigurationRoot BuildConfiguration(string basePath) + private static IConfigurationRoot BuildConfiguration(IHostingEnvironment env) { var builder = new ConfigurationBuilder() - .SetBasePath(basePath) - .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); + .SetBasePath(env.ContentRootPath) + .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) + .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true); return builder.Build(); } diff --git a/src/AbpDesk/AbpDesk.Web.Mvc/Dockerfile b/src/AbpDesk/AbpDesk.Web.Mvc/Dockerfile new file mode 100644 index 0000000000..ef8ba190bf --- /dev/null +++ b/src/AbpDesk/AbpDesk.Web.Mvc/Dockerfile @@ -0,0 +1,7 @@ +FROM microsoft/aspnetcore + +WORKDIR /app + +COPY . . + +ENTRYPOINT ["dotnet", "AbpDesk.Web.Mvc.dll"] \ No newline at end of file diff --git a/src/AbpDesk/AbpDesk.Web.Mvc/appsettings.Staging.json b/src/AbpDesk/AbpDesk.Web.Mvc/appsettings.Staging.json new file mode 100644 index 0000000000..3a6dc58fce --- /dev/null +++ b/src/AbpDesk/AbpDesk.Web.Mvc/appsettings.Staging.json @@ -0,0 +1,5 @@ +{ + "ConnectionStrings": { + "Default": "Server=192.168.1.36;Database=AbpDesk;User=sa;Password=123qwe;" + } +} diff --git a/src/AbpDesk/AbpDesk.Web.Mvc/project.json b/src/AbpDesk/AbpDesk.Web.Mvc/project.json index 91fdd2d4d4..e8a11f242b 100644 --- a/src/AbpDesk/AbpDesk.Web.Mvc/project.json +++ b/src/AbpDesk/AbpDesk.Web.Mvc/project.json @@ -57,7 +57,9 @@ "Areas", "Views", "web.config", - "appsettings.json" + "appsettings.json", + "appsettings.Staging.json", + "Dockerfile" ] },