Added docker configuration.

pull/81/head
Halil İbrahim Kalkan 9 years ago
parent ac05e0cc3a
commit 45a1bb721d

@ -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

@ -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

@ -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"

@ -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

@ -20,7 +20,7 @@ namespace AbpDesk.Web.Mvc
public override void ConfigureServices(IServiceCollection services)
{
var hostingEnvironment = services.GetSingletonInstance<IHostingEnvironment>();
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();
}

@ -0,0 +1,7 @@
FROM microsoft/aspnetcore
WORKDIR /app
COPY . .
ENTRYPOINT ["dotnet", "AbpDesk.Web.Mvc.dll"]

@ -0,0 +1,5 @@
{
"ConnectionStrings": {
"Default": "Server=192.168.1.36;Database=AbpDesk;User=sa;Password=123qwe;"
}
}

@ -57,7 +57,9 @@
"Areas",
"Views",
"web.config",
"appsettings.json"
"appsettings.json",
"appsettings.Staging.json",
"Dockerfile"
]
},

Loading…
Cancel
Save