Add project files.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
**/.classpath
|
||||
**/.dockerignore
|
||||
**/.env
|
||||
**/.git
|
||||
**/.gitignore
|
||||
**/.project
|
||||
**/.settings
|
||||
**/.toolstarget
|
||||
**/.vs
|
||||
**/.vscode
|
||||
**/*.*proj.user
|
||||
**/*.dbmdl
|
||||
**/*.jfm
|
||||
**/azds.yaml
|
||||
**/bin
|
||||
**/charts
|
||||
**/docker-compose*
|
||||
**/Dockerfile*
|
||||
**/node_modules
|
||||
**/npm-debug.log
|
||||
**/obj
|
||||
**/secrets.dev.yaml
|
||||
**/values.dev.yaml
|
||||
LICENSE
|
||||
README.md
|
||||
@@ -0,0 +1,37 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.6.33815.320
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TURN.Services.Chess", "TURN.Services.Chess\TURN.Services.Chess.csproj", "{8D4377EA-91FB-464B-8B16-3BEE15F56616}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TURN.Libraries.Core", "TURN.Libraries.Core\TURN.Libraries.Core.csproj", "{54ACF6B1-2512-47C4-877A-5B78E9001B8C}"
|
||||
EndProject
|
||||
Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{9E564C7C-C521-47AC-9CD1-F475B2E4174C}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{8D4377EA-91FB-464B-8B16-3BEE15F56616}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{8D4377EA-91FB-464B-8B16-3BEE15F56616}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{8D4377EA-91FB-464B-8B16-3BEE15F56616}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{8D4377EA-91FB-464B-8B16-3BEE15F56616}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{54ACF6B1-2512-47C4-877A-5B78E9001B8C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{54ACF6B1-2512-47C4-877A-5B78E9001B8C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{54ACF6B1-2512-47C4-877A-5B78E9001B8C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{54ACF6B1-2512-47C4-877A-5B78E9001B8C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{9E564C7C-C521-47AC-9CD1-F475B2E4174C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9E564C7C-C521-47AC-9CD1-F475B2E4174C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9E564C7C-C521-47AC-9CD1-F475B2E4174C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9E564C7C-C521-47AC-9CD1-F475B2E4174C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {14F45E3F-FCDD-4DA0-99D5-E88D10CF7C4F}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using NLog;
|
||||
using NLog.Targets;
|
||||
|
||||
namespace TURN.Libraries.Core
|
||||
{
|
||||
public static class LoggerFactory
|
||||
{
|
||||
public static Logger GetLogger()
|
||||
{
|
||||
return LogManager.Setup().LoadConfiguration(c =>
|
||||
{
|
||||
ColoredConsoleTarget consoleTarget = new ColoredConsoleTarget()
|
||||
{
|
||||
Layout = "${date}|${level:uppercase=true}|${message:withexception=true}"
|
||||
};
|
||||
FileTarget fileTarget = new FileTarget()
|
||||
{
|
||||
FileName = Environment.GetEnvironmentVariable("LOG_FILE_PATH"),
|
||||
Layout = "${date}|${level:uppercase=true}|${message:withexception=true}",
|
||||
Encoding = Encoding.UTF8,
|
||||
LineEnding = LineEndingMode.CRLF,
|
||||
KeepFileOpen = true,
|
||||
ConcurrentWrites = true,
|
||||
ArchiveAboveSize = long.Parse(Environment.GetEnvironmentVariable("LOG_FILE_SIZE")),
|
||||
MaxArchiveFiles = 10,
|
||||
MaxArchiveDays = 365
|
||||
};
|
||||
|
||||
_ = c.ForLogger("consoleAndFile")
|
||||
.FilterMinLevel(LogLevel.Debug)
|
||||
.WriteTo(consoleTarget)
|
||||
.WriteTo(fileTarget);
|
||||
}).GetLogger("consoleAndFile");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("TURN.Libraries.Core")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("*")]
|
||||
[assembly: AssemblyProduct("TURN.Libraries.Core")]
|
||||
[assembly: AssemblyCopyright("Copyright © * 2023")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("54acf6b1-2512-47c4-877a-5b78e9001b8c")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{54ACF6B1-2512-47C4-877A-5B78E9001B8C}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>TURN.Libraries.Core</RootNamespace>
|
||||
<AssemblyName>TURN.Libraries.Core</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NLog.5.2.0\lib\net46\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.IO.Compression" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="LoggerFactory.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="NLog" version="5.2.0" targetFramework="net48" />
|
||||
</packages>
|
||||
@@ -0,0 +1,25 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace TURN.Services.Chess.Controllers
|
||||
{
|
||||
[Route("/[controller]")]
|
||||
[ApiController]
|
||||
public class TurnController : ControllerBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Тестовый гет.
|
||||
/// </summary>
|
||||
[HttpGet("test/{param}")]
|
||||
public ActionResult<string> Get(string param)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Ok(param);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return StatusCode(500, $"Internal server error: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
|
||||
WORKDIR /app
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
|
||||
WORKDIR /src
|
||||
COPY ["TURN.Services.Chess/TURN.Services.Chess.csproj", "TURN.Services.Chess/"]
|
||||
COPY ["TURN.Libraries.Core/TURN.Libraries.Core.csproj", "TURN.Libraries.Core/"]
|
||||
RUN dotnet restore "TURN.Services.Chess/TURN.Services.Chess.csproj"
|
||||
COPY . .
|
||||
WORKDIR "/src/TURN.Services.Chess"
|
||||
RUN dotnet build "TURN.Services.Chess.csproj" -c Release -o /app/build
|
||||
|
||||
FROM build AS publish
|
||||
RUN dotnet publish "TURN.Services.Chess.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
||||
|
||||
FROM base AS final
|
||||
WORKDIR /app
|
||||
COPY --from=publish /app/publish .
|
||||
ENTRYPOINT ["dotnet", "TURN.Services.Chess.dll"]
|
||||
@@ -0,0 +1,26 @@
|
||||
using Microsoft.AspNetCore;
|
||||
using TURN.Services.Chess;
|
||||
using LoggerFactory = TURN.Libraries.Core.LoggerFactory;
|
||||
|
||||
NLog.Logger logger = LoggerFactory.GetLogger();
|
||||
logger.Info("Chess app starting.");
|
||||
|
||||
try
|
||||
{
|
||||
IWebHost host = BuildWebHost(args);
|
||||
host.Run();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error(ex);
|
||||
}
|
||||
|
||||
IWebHost BuildWebHost(string[] args) => WebHost
|
||||
.CreateDefaultBuilder(args)
|
||||
.CaptureStartupErrors(false)
|
||||
.ConfigureServices(services =>
|
||||
{
|
||||
_ = services.AddSingleton(logger);
|
||||
})
|
||||
.UseStartup<Startup>()
|
||||
.Build();
|
||||
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"dotnetRunMessages": true,
|
||||
"applicationUrl": "http://localhost:5110"
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"Docker": {
|
||||
"commandName": "Docker",
|
||||
"publishAllPorts": true
|
||||
}
|
||||
},
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:12777",
|
||||
"sslPort": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
using System.Reflection;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace TURN.Services.Chess
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
ConfigureSwagger(services);
|
||||
_ = services.AddControllers();
|
||||
_ = services.AddControllers().AddNewtonsoftJson(jsonOptions =>
|
||||
{
|
||||
jsonOptions.SerializerSettings.Converters.Add(new StringEnumConverter());
|
||||
});
|
||||
//_ = services.AddDbContext<ModelBaseContext>(
|
||||
// options => options.UseSqlServer(Environment.GetEnvironmentVariable("DB")));
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app)
|
||||
{
|
||||
_ = app.UseRouting();
|
||||
_ = app.UseSwagger();
|
||||
_ = app.UseSwaggerUI();
|
||||
_ = app.UseEndpoints(endpoints =>
|
||||
{
|
||||
_ = endpoints.MapControllers();
|
||||
_ = endpoints.MapControllerRoute(
|
||||
name: "default",
|
||||
pattern: "{controller}/{action}");
|
||||
_ = endpoints.MapSwagger();
|
||||
});
|
||||
}
|
||||
|
||||
private void ConfigureSwagger(IServiceCollection services)
|
||||
{
|
||||
_ = services.AddSwaggerGen(options =>
|
||||
{
|
||||
options.SwaggerDoc("v1", new OpenApiInfo
|
||||
{
|
||||
Title = "TURN.Api.Swagger",
|
||||
Version = "v1"
|
||||
});
|
||||
string xmlFilename = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
|
||||
options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, xmlFilename));
|
||||
});
|
||||
_ = services.AddSwaggerGenNewtonsoftSupport();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<NoWarn>$(NoWarn);1591</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="7.0.8" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.18.1" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="NLog" Version="5.2.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.Newtonsoft" Version="6.5.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.5.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.5.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\TURN.Libraries.Core\TURN.Libraries.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" Sdk="Microsoft.Docker.Sdk">
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectVersion>2.1</ProjectVersion>
|
||||
<DockerTargetOS>Linux</DockerTargetOS>
|
||||
<ProjectGuid>9e564c7c-c521-47ac-9cd1-f475b2e4174c</ProjectGuid>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Include="docker-compose.yml" />
|
||||
<None Include=".dockerignore" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,42 @@
|
||||
version: '3.4'
|
||||
|
||||
services:
|
||||
chess:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: TURN.Services.Chess\Dockerfile
|
||||
environment:
|
||||
- LOG_FILE_PATH=/logs/log.log
|
||||
- LOG_FILE_SIZE=50000000
|
||||
ports:
|
||||
- 80:80
|
||||
volumes:
|
||||
- /d/programming/ChessData:/logs
|
||||
networks:
|
||||
- app-network
|
||||
|
||||
postgresdb:
|
||||
image: postgres
|
||||
restart: always
|
||||
ports:
|
||||
- 5432:5432
|
||||
environment:
|
||||
- POSTGRES_DB=TURNChese
|
||||
- POSTGRES_PASSWORD=example
|
||||
- PGDATA=/var/lib/postgresql/data/pgdata
|
||||
volumes:
|
||||
- /d/programming/ChessData/pgdata:/var/lib/postgresql/data
|
||||
networks:
|
||||
- app-network
|
||||
|
||||
adminer:
|
||||
image: adminer
|
||||
restart: always
|
||||
ports:
|
||||
- 8080:8080
|
||||
networks:
|
||||
- app-network
|
||||
|
||||
networks:
|
||||
app-network:
|
||||
driver: bridge
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"profiles": {
|
||||
"Docker Compose": {
|
||||
"commandName": "DockerCompose",
|
||||
"commandVersion": "1.0",
|
||||
"serviceActions": {
|
||||
"turn.services.chess": "StartDebugging"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user