.NET 5 upgrade
parent
b9ef2f94bb
commit
1f82f79288
|
@ -1,7 +1,7 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.0</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.0</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.0</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@
|
||||||
<PackageReference Include="Serilog.Sinks.MSSqlServer" Version="$(SerilogSinksMSSqlServerPackageVersion)" />
|
<PackageReference Include="Serilog.Sinks.MSSqlServer" Version="$(SerilogSinksMSSqlServerPackageVersion)" />
|
||||||
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="$(AutoMapperExtensionsPackageVersion)" />
|
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="$(AutoMapperExtensionsPackageVersion)" />
|
||||||
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="$(MediatRPackageVersion)" />
|
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="$(MediatRPackageVersion)" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="$(SwashbucklePackageVersion)" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
|
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
|
||||||
|
|
||||||
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
|
#ARG BASE_IMAGE="buster-slim"
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim AS base
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
|
FROM mcr.microsoft.com/dotnet/sdk:5.0-buster-slim AS build
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
COPY dependencies.props .
|
COPY dependencies.props .
|
||||||
COPY Directory.Build.props .
|
COPY Directory.Build.props .
|
||||||
|
@ -30,6 +32,9 @@ ENV ConnectionStrings__DatabaseConnection="***REMOVED***"
|
||||||
ENV TZ=Europe/Bucharest
|
ENV TZ=Europe/Bucharest
|
||||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||||
|
|
||||||
|
ARG APP_VERSION=0.0.0.0
|
||||||
|
ENV APP_VERSION=${APP_VERSION}
|
||||||
|
|
||||||
#Workaround to lower the TLS level in container for old sql server version
|
#Workaround to lower the TLS level in container for old sql server version
|
||||||
RUN sed -i 's/TLSv1.2/TLSv1.0/g' /etc/ssl/openssl.cnf
|
RUN sed -i 's/TLSv1.2/TLSv1.0/g' /etc/ssl/openssl.cnf
|
||||||
|
|
||||||
|
|
|
@ -32,19 +32,25 @@ namespace Chatbot.Api
|
||||||
var connectionString = configuration.GetConnectionString("DatabaseConnection");
|
var connectionString = configuration.GetConnectionString("DatabaseConnection");
|
||||||
var loggingLevelParam = configuration.GetValue<string>("Logging:LogLevel:Default");
|
var loggingLevelParam = configuration.GetValue<string>("Logging:LogLevel:Default");
|
||||||
|
|
||||||
Enum.TryParse(loggingLevelParam, out LogEventLevel loggingLevel);
|
var loggingLevelOk = Enum.TryParse(loggingLevelParam, out LogEventLevel loggingLevel);
|
||||||
|
if (!loggingLevelOk)
|
||||||
|
throw new Exception($"Logging level '{loggingLevelParam}' is not valid.");
|
||||||
|
|
||||||
var loggingLevelSwitch = new LoggingLevelSwitch(loggingLevel);
|
var loggingLevelSwitch = new LoggingLevelSwitch(loggingLevel);
|
||||||
|
|
||||||
var columnOptions = new ColumnOptions();
|
var columnOptions = new ColumnOptions();
|
||||||
columnOptions.Store.Remove(StandardColumn.Properties);
|
columnOptions.Store.Remove(StandardColumn.Properties);
|
||||||
columnOptions.Store.Remove(StandardColumn.MessageTemplate);
|
columnOptions.Store.Remove(StandardColumn.MessageTemplate);
|
||||||
columnOptions.Store.Add(StandardColumn.LogEvent);
|
columnOptions.Store.Add(StandardColumn.LogEvent);
|
||||||
|
|
||||||
|
var mssqlSinkOptions = new MSSqlServerSinkOptions() { AutoCreateSqlTable = true, TableName = "__Logs" };
|
||||||
|
|
||||||
Log.Logger = new LoggerConfiguration()
|
Log.Logger = new LoggerConfiguration()
|
||||||
.MinimumLevel.ControlledBy(loggingLevelSwitch)
|
.MinimumLevel.ControlledBy(loggingLevelSwitch)
|
||||||
.MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
|
.MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
|
||||||
.Enrich.FromLogContext()
|
.Enrich.FromLogContext()
|
||||||
.WriteTo.Console()
|
.WriteTo.Console()
|
||||||
.WriteTo.MSSqlServer(connectionString, "__Logs", autoCreateSqlTable: true, columnOptions: columnOptions)
|
.WriteTo.MSSqlServer(connectionString, mssqlSinkOptions, columnOptions: columnOptions)
|
||||||
.CreateLogger();
|
.CreateLogger();
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -65,13 +71,18 @@ namespace Chatbot.Api
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IHostBuilder CreateHostBuilder(string[] args, IConfiguration configuration) =>
|
public static IHostBuilder CreateHostBuilder(string[] args, IConfiguration configuration)
|
||||||
Host.CreateDefaultBuilder(args)
|
{
|
||||||
|
var builder = Host.CreateDefaultBuilder(args)
|
||||||
.ConfigureWebHostDefaults(webBuilder =>
|
.ConfigureWebHostDefaults(webBuilder =>
|
||||||
{
|
{
|
||||||
webBuilder.UseStartup<Startup>()
|
webBuilder.UseStartup<Startup>()
|
||||||
.UseConfiguration(configuration)
|
.UseConfiguration(configuration);
|
||||||
.UseSerilog();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
builder.UseSerilog();
|
||||||
|
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"urls": "http://*:5061",
|
"urls": "http://*:5055",
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"DatabaseConnection": "***REMOVED***"
|
"DatabaseConnection": "***REMOVED***"
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio Version 16
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 16.0.30002.166
|
VisualStudioVersion = 17.2.32526.322
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Chatbot.Api", "Chatbot.Api\Chatbot.Api.csproj", "{E317DE66-9513-4666-ADCC-0B7D5B652378}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Chatbot.Api", "Chatbot.Api\Chatbot.Api.csproj", "{E317DE66-9513-4666-ADCC-0B7D5B652378}"
|
||||||
EndProject
|
EndProject
|
||||||
|
@ -25,8 +25,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Api", "Api", "{3AC727D4-4E6
|
||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{341EE785-7F03-457F-9188-0ADB1A2B9DBD}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{341EE785-7F03-457F-9188-0ADB1A2B9DBD}"
|
||||||
ProjectSection(SolutionItems) = preProject
|
ProjectSection(SolutionItems) = preProject
|
||||||
build-amd64.sh = build-amd64.sh
|
buildx.sh = buildx.sh
|
||||||
release.sh = release.sh
|
release.sh = release.sh
|
||||||
|
build.sh = build.sh
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
#!/bin/bash
|
||||||
|
echo "Welcome!"
|
||||||
|
|
||||||
|
#version="1.0.1"
|
||||||
|
#platform="linux/amd64,linux/arm64"
|
||||||
|
version="1.0.1-arm64"
|
||||||
|
platform="linux/arm64"
|
||||||
|
localRegistryPass="***REMOVED***"
|
||||||
|
|
||||||
|
echo "Login to alpine-nexus registry."
|
||||||
|
docker login --username=admin --password=$localRegistryPass alpine-nexus:8500
|
||||||
|
|
||||||
|
echo "Create docker image with version $version for platform $platform"
|
||||||
|
docker buildx build \
|
||||||
|
--build-arg APP_VERSION=$version \
|
||||||
|
--platform $platform \
|
||||||
|
--output=type=image,push=true,registry.insecure=true \
|
||||||
|
--push \
|
||||||
|
--tag alpine-nexus:8500/chatbot/chatbot-api:$version \
|
||||||
|
-f "Chatbot.Api/Dockerfile" .
|
||||||
|
|
||||||
|
echo "Done!"
|
|
@ -1,16 +1,15 @@
|
||||||
<Project>
|
<Project>
|
||||||
<PropertyGroup Label="Package Versions">
|
<PropertyGroup Label="Package Versions">
|
||||||
<MicrosoftExtensionsPackageVersion>3.1.3</MicrosoftExtensionsPackageVersion>
|
<MicrosoftExtensionsPackageVersion>5.0.0</MicrosoftExtensionsPackageVersion>
|
||||||
<SerilogPackageVersion>3.2.0</SerilogPackageVersion>
|
<SerilogPackageVersion>5.0.0</SerilogPackageVersion>
|
||||||
<SerilogExtensionsPackageVersion>3.0.1</SerilogExtensionsPackageVersion>
|
<SerilogExtensionsPackageVersion>3.1.0</SerilogExtensionsPackageVersion>
|
||||||
<SerilogSinksConsolePackageVersion>3.1.1</SerilogSinksConsolePackageVersion>
|
<SerilogSinksConsolePackageVersion>4.0.1</SerilogSinksConsolePackageVersion>
|
||||||
<SerilogSinksMSSqlServerPackageVersion>5.2.0</SerilogSinksMSSqlServerPackageVersion>
|
<SerilogSinksMSSqlServerPackageVersion>5.7.0</SerilogSinksMSSqlServerPackageVersion>
|
||||||
<AutoMapperPackageVersion>9.0.0</AutoMapperPackageVersion>
|
<AutoMapperPackageVersion>10.1.1</AutoMapperPackageVersion>
|
||||||
<AutoMapperExtensionsPackageVersion>7.0.0</AutoMapperExtensionsPackageVersion>
|
<AutoMapperExtensionsPackageVersion>8.1.1</AutoMapperExtensionsPackageVersion>
|
||||||
<MediatRPackageVersion>6.0.0</MediatRPackageVersion>
|
<MediatRPackageVersion>6.0.0</MediatRPackageVersion>
|
||||||
<SwashbucklePackageVersion>5.3.1</SwashbucklePackageVersion>
|
<EntityFrameworkCorePackageVersion>5.0.12</EntityFrameworkCorePackageVersion>
|
||||||
<EntityFrameworkCorePackageVersion>3.1.3</EntityFrameworkCorePackageVersion>
|
<NDBExtensionsPackageVersion>1.0.2</NDBExtensionsPackageVersion>
|
||||||
<NDBExtensionsPackageVersion>1.0.0</NDBExtensionsPackageVersion>
|
|
||||||
<NDBApplicationPackageVersion>1.0.0</NDBApplicationPackageVersion>
|
<NDBApplicationPackageVersion>1.0.0</NDBApplicationPackageVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
Loading…
Reference in New Issue