Skip to content

Commit 4549980

Browse files
committed
Merge remote-tracking branch 'origin/windows-containers-test' into dev
2 parents 5d8628c + 3ec61e0 commit 4549980

13 files changed

Lines changed: 607 additions & 0 deletions

File tree

_docker/redis/Dockerfile.nanowin

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# The MSI installs a service which is hard to override, so let's use a zip file.
2+
3+
FROM microsoft/windowsservercore
4+
MAINTAINER alexellis2@gmail.com
5+
6+
SHELL ["powershell"]
7+
RUN $ErrorActionPreference = 'Stop'; \
8+
wget https://github.com/MSOpenTech/redis/releases/download/win-3.2.100/Redis-x64-3.2.100.zip -OutFile Redis-x64-3.2.100.zip ; \
9+
Expand-Archive Redis-x64-3.2.100.zip -dest 'C:\\Program Files\\Redis\\' ; \
10+
Remove-Item Redis-x64-3.2.100.zip -Force
11+
12+
RUN setx PATH '%PATH%;C:\\Program Files\\Redis\\'
13+
WORKDIR 'C:\\Program Files\\Redis\\'
14+
15+
16+
17+
RUN Get-Content redis.windows.conf | Where { $_ -notmatch 'bind 127.0.0.1' } | Set-Content redis.openport.conf ; \
18+
Get-Content redis.openport.conf | Where { $_ -notmatch 'protected-mode yes' } | Set-Content redis.unprotected.conf ; \
19+
Add-Content redis.unprotected.conf 'protected-mode no' ; \
20+
Add-Content redis.unprotected.conf 'bind 0.0.0.0' ; \
21+
Get-Content redis.unprotected.conf
22+
23+
EXPOSE 6379
24+
25+
RUN set-itemproperty -path 'HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters' -Name ServerPriorityTimeLimit -Value 0 -Type DWord
26+
27+
# Define our command to be run when launching the container
28+
CMD .\\redis-server.exe .\\redis.unprotected.conf --port 6379 ; \
29+
Write-Host Redis Started... ; \
30+
while ($true) { Start-Sleep -Seconds 3600 }
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM microsoft/dotnet:1.1-runtime-nanoserver
2+
ARG source
3+
WORKDIR /app
4+
RUN set-itemproperty -path 'HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters' -Name ServerPriorityTimeLimit -Value 0 -Type DWord
5+
EXPOSE 80
6+
COPY ${source:-obj/Docker/publish} .
7+
ENTRYPOINT ["dotnet", "Basket.API.dll"]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM microsoft/dotnet:1.1-runtime-nanoserver
2+
ARG source
3+
WORKDIR /app
4+
RUN set-itemproperty -path 'HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters' -Name ServerPriorityTimeLimit -Value 0 -Type DWord
5+
EXPOSE 80
6+
COPY ${source:-obj/Docker/publish} .
7+
ENTRYPOINT ["dotnet", "Catalog.API.dll"]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM microsoft/dotnet:1.1-runtime-nanoserver
2+
ARG source
3+
WORKDIR /app
4+
RUN set-itemproperty -path 'HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters' -Name ServerPriorityTimeLimit -Value 0 -Type DWord
5+
EXPOSE 80
6+
COPY ${source:-obj/Docker/publish} .
7+
ENTRYPOINT ["dotnet", "Identity.API.dll"]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM microsoft/dotnet:1.1-runtime-nanoserver
2+
ARG source
3+
WORKDIR /app
4+
RUN set-itemproperty -path 'HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters' -Name ServerPriorityTimeLimit -Value 0 -Type DWord
5+
EXPOSE 80
6+
COPY ${source:-obj/Docker/publish} .
7+
ENTRYPOINT ["dotnet", "Ordering.API.dll"]

src/Web/Catalog.WebForms/Catalog.WebForms/Catalog.WebForms.csproj

Lines changed: 305 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using Autofac;
2+
using Autofac.Core;
3+
using eShopOnContainers.Core.Models.Catalog;
4+
using eShopOnContainers.Core.Services.Catalog;
5+
using System;
6+
using System.Collections.Generic;
7+
using System.Linq;
8+
using System.Threading.Tasks;
9+
using System.Web;
10+
using System.Web.UI;
11+
using System.Web.UI.WebControls;
12+
13+
namespace Microsoft.eShopOnContainers.Catalog.WebForms
14+
{
15+
public partial class _Default : Page
16+
{
17+
private ICatalogService catalog;
18+
19+
protected _Default() { }
20+
21+
public _Default(ICatalogService catalog)
22+
{
23+
this.catalog = catalog;
24+
}
25+
26+
protected override void OnLoad(EventArgs e)
27+
{
28+
RegisterAsyncTask(new PageAsyncTask(LoadCatalogDataAsync));
29+
30+
base.OnLoad(e);
31+
}
32+
33+
private async Task LoadCatalogDataAsync()
34+
{
35+
var collection = await catalog?.GetCatalogAsync();
36+
catalogList.DataSource = collection;
37+
catalogList.DataBind();
38+
}
39+
40+
protected void Page_Load(object sender, EventArgs e)
41+
{
42+
43+
}
44+
}
45+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System;
2+
using System.Web;
3+
using System.Web.Optimization;
4+
using System.Web.Routing;
5+
6+
namespace Microsoft.eShopOnContainers.Catalog.WebForms
7+
{
8+
public class Global : HttpApplication
9+
{
10+
11+
void Application_Start(object sender, EventArgs e)
12+
{
13+
// Code that runs on application startup
14+
RouteConfig.RegisterRoutes(RouteTable.Routes);
15+
BundleConfig.RegisterBundles(BundleTable.Bundles);
16+
17+
}
18+
}
19+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
using Autofac;
2+
using eShopOnContainers.Core.Services.Catalog;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Web;
7+
using System.Web.Configuration;
8+
using System.Web.UI;
9+
10+
namespace Microsoft.eShopOnContainers.Catalog.WebForms.Modules
11+
{
12+
// Using DI with WebForms is not yet implemented.
13+
// This implementation has been adapted from this post:
14+
// https://blogs.msdn.microsoft.com/webdev/2016/10/19/modern-asp-net-web-forms-development-dependency-injection/
15+
16+
public class AutoFacHttpModule : IHttpModule
17+
{
18+
private static IContainer Container => lazyContainer.Value;
19+
20+
private static Lazy<IContainer> lazyContainer = new Lazy<IContainer>(() => CreateContainer());
21+
22+
private static IContainer CreateContainer()
23+
{
24+
// Configure AutoFac:
25+
// Register Containers:
26+
var settings = WebConfigurationManager.AppSettings;
27+
var useFake = settings["usefake"];
28+
bool fake = useFake == "true";
29+
var builder = new ContainerBuilder();
30+
if (fake)
31+
{
32+
builder.RegisterType<CatalogMockService>()
33+
.As<ICatalogService>();
34+
}
35+
else
36+
{
37+
builder.RegisterType<CatalogMockService>()
38+
.As<ICatalogService>();
39+
}
40+
var container = builder.Build();
41+
return container;
42+
}
43+
44+
public void Dispose()
45+
{
46+
Container.Dispose();
47+
}
48+
49+
public void Init(HttpApplication context)
50+
{
51+
context.PreRequestHandlerExecute += (_, __) => InjectDependencies();
52+
}
53+
54+
private void InjectDependencies()
55+
{
56+
if (HttpContext.Current.CurrentHandler is Page page)
57+
{
58+
// Get the code-behind class that we may have written
59+
var pageType = page.GetType().BaseType;
60+
61+
// Determine if there is a constructor to inject, and grab it
62+
var ctor = (from c in pageType.GetConstructors()
63+
where c.GetParameters().Length > 0
64+
select c).FirstOrDefault();
65+
66+
if (ctor != null)
67+
{
68+
// Resolve the parameters for the constructor
69+
var args = (from parm in ctor.GetParameters()
70+
select Container.Resolve(parm.ParameterType))
71+
.ToArray();
72+
73+
// Execute the constructor method with the arguments resolved
74+
ctor.Invoke(page, args);
75+
}
76+
77+
// Use the Autofac method to inject any properties that can be filled by Autofac
78+
Container.InjectProperties(page);
79+
80+
}
81+
}
82+
}
83+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
For more information on how to configure your ASP.NET application, please visit
4+
https://go.microsoft.com/fwlink/?LinkId=169433
5+
-->
6+
<configuration>
7+
<appSettings>
8+
<add key="usefake" value="true" />
9+
</appSettings>
10+
<system.web>
11+
<compilation debug="true" targetFramework="4.5.2" />
12+
<httpRuntime targetFramework="4.5.2" />
13+
<pages>
14+
<namespaces>
15+
<add namespace="System.Web.Optimization" />
16+
</namespaces>
17+
<controls>
18+
<add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt" />
19+
</controls>
20+
</pages>
21+
<httpModules>
22+
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" />
23+
<!-- Use this if you are on IIS 7 and earlier -->
24+
<add name="InjectModule" type="Microsoft.eShopOnContainers.Catalog.WebForms.Modules.AutoFacHttpModule, Catalog.WebForms" />
25+
</httpModules>
26+
</system.web>
27+
<runtime>
28+
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
29+
<dependentAssembly>
30+
<assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
31+
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
32+
</dependentAssembly>
33+
<dependentAssembly>
34+
<assemblyIdentity name="WebGrease" culture="neutral" publicKeyToken="31bf3856ad364e35" />
35+
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
36+
</dependentAssembly>
37+
</assemblyBinding>
38+
</runtime>
39+
<system.webServer>
40+
<validation validateIntegratedModeConfiguration="false" />
41+
<modules>
42+
<remove name="ApplicationInsightsWebTracking" />
43+
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" />
44+
<!-- Use this if you are on IIS 8 and later -->
45+
<add name="InjectModule" type="Microsoft.eShopOnContainers.Catalog.WebForms.Modules.AutoFacHttpModule, Catalog.WebForms" />
46+
</modules>
47+
</system.webServer>
48+
<system.codedom>
49+
<compilers>
50+
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
51+
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
52+
</compilers>
53+
</system.codedom>
54+
</configuration>

0 commit comments

Comments
 (0)