Skip to content

Commit

Permalink
Merge pull request #7 from SyncfusionExamples/DockerProjectUpgrade
Browse files Browse the repository at this point in the history
Updated docker project to .net 6
  • Loading branch information
dskesavan committed Sep 8, 2023
2 parents 78cfb82 + 22d55fe commit 98af095
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 25 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
@@ -1,11 +1,11 @@
FROM mcr.microsoft.com/dotnet/aspnet:2.1 AS base
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
ENV SYNCFUSION_LICENSE_KEY=""
ENV SPELLCHECK_DICTIONARY_PATH=""
ENV SPELLCHECK_JSON_FILENAME=""
ENV SPELLCHECK_CACHE_COUNT=""
FROM mcr.microsoft.com/dotnet/sdk:2.1 AS build
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build

WORKDIR /source
COPY ["src/ej2-documenteditor-server/ej2-documenteditor-server.csproj", "./ej2-documenteditor-server/ej2-documenteditor-server.csproj"]
Expand Down
40 changes: 26 additions & 14 deletions src/ej2-documenteditor-server/Startup.cs
Expand Up @@ -9,7 +9,6 @@
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Microsoft.EntityFrameworkCore;
using Microsoft.Data.Edm;
using Microsoft.AspNet.OData.Builder;
using Microsoft.AspNet.OData.Extensions;
using Microsoft.AspNetCore.Routing;
Expand All @@ -19,6 +18,8 @@
using Syncfusion.EJ2.SpellChecker;
using System.IO;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using Microsoft.AspNetCore.ResponseCompression;

namespace EJ2DocumentEditorServer
{
Expand Down Expand Up @@ -63,27 +64,30 @@ public Startup(IConfiguration configuration, IHostingEnvironment env)
}

public IConfiguration Configuration { get; }

readonly string MyAllowSpecificOrigins = "MyPolicy";
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddOData();
services.AddMvc().AddJsonOptions(x => {
x.SerializerSettings.ContractResolver = null;
services.AddControllers();
services.AddMemoryCache();
services.AddControllers().AddNewtonsoftJson(options =>
{
// Use the default property (Pascal) casing
options.SerializerSettings.ContractResolver = new DefaultContractResolver();
});

services.AddCors(options =>
{
options.AddPolicy("AllowAllOrigins", builder =>
options.AddPolicy(MyAllowSpecificOrigins,
builder =>
{
builder.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader();
.AllowAnyMethod()
.AllowAnyHeader();
});
});

// Add framework services.
services.AddMvc();
services.Configure<GzipCompressionProviderOptions>(options => options.Level = System.IO.Compression.CompressionLevel.Optimal);
services.AddResponseCompression();
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
Expand All @@ -98,10 +102,18 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseDeveloperExceptionPage();
}

app.UseMvc(routes =>
else
{
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthorization();
app.UseCors(MyAllowSpecificOrigins);
app.UseResponseCompression();
app.UseEndpoints(endpoints =>
{
routes.MapRoute("default", "{api}/{controller}/{action}/{id?}");
endpoints.MapControllers().RequireCors("MyPolicy");
});
}

Expand Down
11 changes: 4 additions & 7 deletions src/ej2-documenteditor-server/ej2-documenteditor-server.csproj
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
Expand Down Expand Up @@ -34,19 +34,16 @@
<Folder Include="wwwroot\" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.5" />
</ItemGroup>

<ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.2" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.21" />
<PackageReference Include="Microsoft.AspNetCore.OData" Version="7.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.1.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.0.2105168" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.2" />
<PackageReference Include="Npgsql" Version="4.0.2" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="2.1.1.1" />
<PackageReference Include="Syncfusion.Compression.Net.Core" Version="*" />
Expand Down
4 changes: 2 additions & 2 deletions src/ej2-documenteditor-server/web.config
Expand Up @@ -10,9 +10,9 @@
</requestFiltering>
</security>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" arguments="%LAUNCHER_ARGS%">
<aspNetCore processPath="%LAUNCHER_PATH%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" arguments="%LAUNCHER_ARGS%" hostingModel="InProcess">
<environmentVariables />
</aspNetCore>
</system.webServer>
Expand Down

0 comments on commit 98af095

Please sign in to comment.