feat(aihit): init + docker + cicd
This commit is contained in:
28
PARR.AIHITSyncerWorker/Dockerfile
Normal file
28
PARR.AIHITSyncerWorker/Dockerfile
Normal file
@@ -0,0 +1,28 @@
|
||||
#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 10.99.253.167:8090/dotnet/runtime:7.0 AS base
|
||||
WORKDIR /app
|
||||
|
||||
FROM 10.99.253.167:8090/dotnet/sdk:7.0 AS build
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
WORKDIR /src
|
||||
COPY ["NuGet.config", "."]
|
||||
COPY ["PARR.AIHITSyncerWorker/PARR.AIHITSyncerWorker.csproj", "PARR.AIHITSyncerWorker/"]
|
||||
COPY ["PARR.AIHITSyncer/PARR.AIHITSyncer.csproj", "PARR.AIHITSyncer/"]
|
||||
COPY ["PARR.BLL/PARR.BLL.csproj", "PARR.BLL/"]
|
||||
COPY ["PARR.DAL/PARR.DAL.csproj", "PARR.DAL/"]
|
||||
COPY ["PARR.Constants/PARR.Constants.csproj", "PARR.Constants/"]
|
||||
RUN dotnet restore "./PARR.AIHITSyncerWorker/./PARR.AIHITSyncerWorker.csproj"
|
||||
COPY . .
|
||||
WORKDIR "/src/PARR.AIHITSyncerWorker"
|
||||
RUN dotnet build "./PARR.AIHITSyncerWorker.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||
|
||||
FROM build AS publish
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
ARG app_version=0.0.0-default
|
||||
RUN dotnet publish "./PARR.AIHITSyncerWorker.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false /p:Version=$app_version
|
||||
|
||||
FROM base AS final
|
||||
WORKDIR /app
|
||||
COPY --from=publish /app/publish .
|
||||
ENTRYPOINT ["dotnet", "PARR.AIHITSyncerWorker.dll"]
|
||||
24
PARR.AIHITSyncerWorker/PARR.AIHITSyncerWorker.csproj
Normal file
24
PARR.AIHITSyncerWorker/PARR.AIHITSyncerWorker.csproj
Normal file
@@ -0,0 +1,24 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Worker">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<UserSecretsId>dotnet-PARR.AIHITSyncerWorker-cd7db85e-5317-46a2-aa90-44eb3e56f076</UserSecretsId>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Elastic.CommonSchema.Serilog" Version="8.6.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.5" />
|
||||
<PackageReference Include="Serilog.Extensions.Hosting" Version="7.0.0" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="7.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\PARR.AIHITSyncer\PARR.AIHITSyncer.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
30
PARR.AIHITSyncerWorker/Program.cs
Normal file
30
PARR.AIHITSyncerWorker/Program.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using PARR.AIHITSyncerWorker;
|
||||
using Elastic.CommonSchema.Serilog;
|
||||
using Serilog;
|
||||
using PARR.AIHITSyncer;
|
||||
|
||||
|
||||
var builder = Host.CreateApplicationBuilder();
|
||||
|
||||
builder.Services.AddLogging(config =>
|
||||
{
|
||||
config.ClearProviders();
|
||||
|
||||
var logger = new LoggerConfiguration();
|
||||
|
||||
if (builder.Environment.IsProduction())
|
||||
logger.WriteTo.Console(new EcsTextFormatter());
|
||||
else
|
||||
logger.WriteTo.Console();
|
||||
|
||||
logger.ReadFrom.Configuration(builder.Configuration);
|
||||
|
||||
config.AddSerilog(logger.CreateLogger());
|
||||
});
|
||||
|
||||
builder.Services.InstallAihitSyncerServices(builder.Configuration);
|
||||
|
||||
builder.Services.AddHostedService<Worker>();
|
||||
|
||||
var host = builder.Build();
|
||||
host.Run();
|
||||
14
PARR.AIHITSyncerWorker/Properties/launchSettings.json
Normal file
14
PARR.AIHITSyncerWorker/Properties/launchSettings.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"profiles": {
|
||||
"PARR.AIHITSyncerWorker": {
|
||||
"commandName": "Project",
|
||||
"environmentVariables": {
|
||||
"DOTNET_ENVIRONMENT": "Development"
|
||||
},
|
||||
"dotnetRunMessages": true
|
||||
},
|
||||
"Docker": {
|
||||
"commandName": "Docker"
|
||||
}
|
||||
}
|
||||
}
|
||||
21
PARR.AIHITSyncerWorker/Worker.cs
Normal file
21
PARR.AIHITSyncerWorker/Worker.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
namespace PARR.AIHITSyncerWorker
|
||||
{
|
||||
public class Worker : BackgroundService
|
||||
{
|
||||
private readonly ILogger<Worker> _logger;
|
||||
|
||||
public Worker(ILogger<Worker> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
while (!stoppingToken.IsCancellationRequested)
|
||||
{
|
||||
_logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
|
||||
await Task.Delay(1000, stoppingToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
8
PARR.AIHITSyncerWorker/appsettings.Development.json
Normal file
8
PARR.AIHITSyncerWorker/appsettings.Development.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
}
|
||||
}
|
||||
8
PARR.AIHITSyncerWorker/appsettings.json
Normal file
8
PARR.AIHITSyncerWorker/appsettings.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user