Skip to content

Commit 98af095

Browse files
authored
Merge pull request #7 from SyncfusionExamples/DockerProjectUpgrade
Updated docker project to .net 6
2 parents 78cfb82 + 22d55fe commit 98af095

File tree

4 files changed

+34
-25
lines changed

4 files changed

+34
-25
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
FROM mcr.microsoft.com/dotnet/aspnet:2.1 AS base
1+
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
22
WORKDIR /app
33
EXPOSE 80
44
ENV SYNCFUSION_LICENSE_KEY=""
55
ENV SPELLCHECK_DICTIONARY_PATH=""
66
ENV SPELLCHECK_JSON_FILENAME=""
77
ENV SPELLCHECK_CACHE_COUNT=""
8-
FROM mcr.microsoft.com/dotnet/sdk:2.1 AS build
8+
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
99

1010
WORKDIR /source
1111
COPY ["src/ej2-documenteditor-server/ej2-documenteditor-server.csproj", "./ej2-documenteditor-server/ej2-documenteditor-server.csproj"]

src/ej2-documenteditor-server/Startup.cs

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
using Microsoft.Extensions.Logging;
1010
using Microsoft.Extensions.Options;
1111
using Microsoft.EntityFrameworkCore;
12-
using Microsoft.Data.Edm;
1312
using Microsoft.AspNet.OData.Builder;
1413
using Microsoft.AspNet.OData.Extensions;
1514
using Microsoft.AspNetCore.Routing;
@@ -19,6 +18,8 @@
1918
using Syncfusion.EJ2.SpellChecker;
2019
using System.IO;
2120
using Newtonsoft.Json;
21+
using Newtonsoft.Json.Serialization;
22+
using Microsoft.AspNetCore.ResponseCompression;
2223

2324
namespace EJ2DocumentEditorServer
2425
{
@@ -63,27 +64,30 @@ public Startup(IConfiguration configuration, IHostingEnvironment env)
6364
}
6465

6566
public IConfiguration Configuration { get; }
66-
67+
readonly string MyAllowSpecificOrigins = "MyPolicy";
6768
// This method gets called by the runtime. Use this method to add services to the container.
6869
public void ConfigureServices(IServiceCollection services)
6970
{
70-
services.AddOData();
71-
services.AddMvc().AddJsonOptions(x => {
72-
x.SerializerSettings.ContractResolver = null;
71+
services.AddControllers();
72+
services.AddMemoryCache();
73+
services.AddControllers().AddNewtonsoftJson(options =>
74+
{
75+
// Use the default property (Pascal) casing
76+
options.SerializerSettings.ContractResolver = new DefaultContractResolver();
7377
});
7478

7579
services.AddCors(options =>
7680
{
77-
options.AddPolicy("AllowAllOrigins", builder =>
81+
options.AddPolicy(MyAllowSpecificOrigins,
82+
builder =>
7883
{
7984
builder.AllowAnyOrigin()
80-
.AllowAnyMethod()
81-
.AllowAnyHeader();
85+
.AllowAnyMethod()
86+
.AllowAnyHeader();
8287
});
8388
});
84-
85-
// Add framework services.
86-
services.AddMvc();
89+
services.Configure<GzipCompressionProviderOptions>(options => options.Level = System.IO.Compression.CompressionLevel.Optimal);
90+
services.AddResponseCompression();
8791
}
8892

8993
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@@ -98,10 +102,18 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
98102
{
99103
app.UseDeveloperExceptionPage();
100104
}
101-
102-
app.UseMvc(routes =>
105+
else
106+
{
107+
app.UseHsts();
108+
}
109+
app.UseHttpsRedirection();
110+
app.UseRouting();
111+
app.UseAuthorization();
112+
app.UseCors(MyAllowSpecificOrigins);
113+
app.UseResponseCompression();
114+
app.UseEndpoints(endpoints =>
103115
{
104-
routes.MapRoute("default", "{api}/{controller}/{action}/{id?}");
116+
endpoints.MapControllers().RequireCors("MyPolicy");
105117
});
106118
}
107119

src/ej2-documenteditor-server/ej2-documenteditor-server.csproj

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.1</TargetFramework>
4+
<TargetFramework>net6.0</TargetFramework>
55
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
66
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
77
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
@@ -34,19 +34,16 @@
3434
<Folder Include="wwwroot\" />
3535
</ItemGroup>
3636

37-
<ItemGroup>
38-
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.5" />
39-
</ItemGroup>
40-
41-
<ItemGroup>
37+
<ItemGroup>
4238
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.2" />
4339
</ItemGroup>
4440

4541
<ItemGroup>
42+
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.21" />
4643
<PackageReference Include="Microsoft.AspNetCore.OData" Version="7.0.1" />
4744
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.1.0" />
4845
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.1.0" />
49-
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.0.2105168" />
46+
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.2" />
5047
<PackageReference Include="Npgsql" Version="4.0.2" />
5148
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="2.1.1.1" />
5249
<PackageReference Include="Syncfusion.Compression.Net.Core" Version="*" />

src/ej2-documenteditor-server/web.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
</requestFiltering>
1111
</security>
1212
<handlers>
13-
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
13+
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
1414
</handlers>
15-
<aspNetCore processPath="%LAUNCHER_PATH%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" arguments="%LAUNCHER_ARGS%">
15+
<aspNetCore processPath="%LAUNCHER_PATH%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" arguments="%LAUNCHER_ARGS%" hostingModel="InProcess">
1616
<environmentVariables />
1717
</aspNetCore>
1818
</system.webServer>

0 commit comments

Comments
 (0)