From 9b914b211dab0995c0b8b940d9db849afbb913fa Mon Sep 17 00:00:00 2001 From: sandre Date: Mon, 27 Mar 2023 21:26:30 +0200 Subject: [PATCH] Update --- .gitignore | 86 +++--- Back/.vscode/launch.json | 35 +++ Back/.vscode/tasks.json | 41 +++ .../skydiveLogs-api.Domain.csproj | 16 +- .../skydiveLogs-api.DomainBusiness.csproj | 2 +- .../skydiveLogs-api.DomainService.csproj | 24 +- .../skydiveLogs-api.Infrastructure.csproj | 34 +-- .../skydiveLogs-api.Ioc.csproj | 45 ++- Back/skydiveLogs-api/Startup.cs | 256 +++++++++--------- Back/skydiveLogs-api/skydiveLogs-api.csproj | 68 ++--- .../skydiveLogs-api.csproj.user | 36 +-- Dockerfile | 56 ++-- doc.txt | 12 +- 13 files changed, 391 insertions(+), 320 deletions(-) create mode 100644 Back/.vscode/launch.json create mode 100644 Back/.vscode/tasks.json diff --git a/.gitignore b/.gitignore index 8881c6d..4c358ad 100644 --- a/.gitignore +++ b/.gitignore @@ -1,42 +1,44 @@ -################################################################################ -# This .gitignore file was automatically created by Microsoft(R) Visual Studio. -################################################################################ - -/Back/skydiveLogs-api/obj -/Back/.vs/skydiveLogs-api/v15 -/Back/skydiveLogs-api/bin -/Back/.vs -/Back/skydiveLogs-api.DomainBusiness/obj -/Back/skydiveLogs-api.Infrastructure/obj -/Back/skydiveLogs-api.Model/obj -/Back/skydiveLogs-api.Model/bin -/Back/skydiveLogs-api.Ioc/bin -/Back/skydiveLogs-api.Ioc/obj -/Back/skydiveLogs-api.Infrastructure/bin -/Back/skydiveLogs-api.DomainBusiness/bin -/Back/dist -/Back/skydiveLogs-api.v3.ncrunchsolution.user -/Back/skydiveLogs-api/Init/twinOtter.jpg -/Back/skydiveLogs-api/Init/skyvan.jpg -/Back/skydiveLogs-api/Init/Pilatus.png -/Back/skydiveLogs-api/Init/pac.jpg -/Back/skydiveLogs-api/Init/dornier.jpg -/Back/skydiveLogs-api/Init/casa.jpg -/Back/skydiveLogs-api/Init/caravan.jpg -/Back/skydiveLogs-api/Init/206.jpg -/Back/skydiveLogs-api/Data -/Back/skydiveLogs-api.DomainService/bin -/Back/skydiveLogs-api.DomainService/obj -/Back/skydiveLogs-api.Data/obj -/Back/skydiveLogs-api.Business/obj -/Back/skydiveLogs-api.Domain/obj -/Back/skydiveLogs-api.Domain/bin/Debug/net5.0 -/Back/skydiveLogs-api.Data/bin/Debug/net5.0 -/Back/skydiveLogs-api.Domain/bin/Release/net5.0/ref/skydiveLogs-api.Domain.dll -/Back/skydiveLogs-api.Domain/bin/Release/net5.0/skydiveLogs-api.Domain.dll -/Back/skydiveLogs-api.Domain/bin/Release/net5.0/skydiveLogs-api.Domain.pdb -/Back/skydiveLogs-api/Data/JumpsDb-log.db -/Back/skydiveLogs-api/Data/JumpsDb.db -Back/skydiveLogs-api/Data/JumpsDb.db -Back/skydiveLogs-api/Data/JumpsDb-log.db -/Back/skydiveLogs-api.Domain/bin/Release/net5.0/skydiveLogs-api.Domain.deps.json +################################################################################ +# This .gitignore file was automatically created by Microsoft(R) Visual Studio. +################################################################################ + +/Back/skydiveLogs-api/obj +/Back/.vs/skydiveLogs-api/v15 +/Back/skydiveLogs-api/bin +/Back/.vs +/Back/skydiveLogs-api.DomainBusiness/obj +/Back/skydiveLogs-api.Infrastructure/obj +/Back/skydiveLogs-api.Model/obj +/Back/skydiveLogs-api.Model/bin +/Back/skydiveLogs-api.Ioc/bin +/Back/skydiveLogs-api.Ioc/obj +/Back/skydiveLogs-api.Infrastructure/bin +/Back/skydiveLogs-api.DomainBusiness/bin +/Back/dist +/Back/skydiveLogs-api.v3.ncrunchsolution.user +/Back/skydiveLogs-api/Init/twinOtter.jpg +/Back/skydiveLogs-api/Init/skyvan.jpg +/Back/skydiveLogs-api/Init/Pilatus.png +/Back/skydiveLogs-api/Init/pac.jpg +/Back/skydiveLogs-api/Init/dornier.jpg +/Back/skydiveLogs-api/Init/casa.jpg +/Back/skydiveLogs-api/Init/caravan.jpg +/Back/skydiveLogs-api/Init/206.jpg +/Back/skydiveLogs-api/Data +/Back/skydiveLogs-api.DomainService/bin +/Back/skydiveLogs-api.DomainService/obj +/Back/skydiveLogs-api.Data/obj +/Back/skydiveLogs-api.Business/obj +/Back/skydiveLogs-api.Domain/obj +/Back/skydiveLogs-api.Domain/bin/Debug/net5.0 +/Back/skydiveLogs-api.Data/bin/Debug/net5.0 +/Back/skydiveLogs-api.Domain/bin/Release/net5.0/ref/skydiveLogs-api.Domain.dll +/Back/skydiveLogs-api.Domain/bin/Release/net5.0/skydiveLogs-api.Domain.dll +/Back/skydiveLogs-api.Domain/bin/Release/net5.0/skydiveLogs-api.Domain.pdb +/Back/skydiveLogs-api/Data/JumpsDb-log.db +/Back/skydiveLogs-api/Data/JumpsDb.db +Back/skydiveLogs-api/Data/JumpsDb.db +Back/skydiveLogs-api/Data/JumpsDb-log.db +/Back/skydiveLogs-api.Domain/bin/Release/net5.0/skydiveLogs-api.Domain.deps.json +/Back/skydiveLogs-api.Domain/bin/Debug/net6.0 +Back/skydiveLogs-api/Data/JumpsDb.db diff --git a/Back/.vscode/launch.json b/Back/.vscode/launch.json new file mode 100644 index 0000000..3c1fb29 --- /dev/null +++ b/Back/.vscode/launch.json @@ -0,0 +1,35 @@ +{ + "version": "0.2.0", + "configurations": [ + { + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md + "name": ".NET Core Launch (web)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/skydiveLogs-api/bin/Debug/net6.0/skydiveLogs-api.dll", + "args": [], + "cwd": "${workspaceFolder}/skydiveLogs-api", + "stopAtEntry": false, + // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser + "serverReadyAction": { + "action": "openExternally", + "pattern": "\\bNow listening on:\\s+(https?://\\S+)" + }, + "env": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "sourceFileMap": { + "/Views": "${workspaceFolder}/Views" + } + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach" + } + ] +} \ No newline at end of file diff --git a/Back/.vscode/tasks.json b/Back/.vscode/tasks.json new file mode 100644 index 0000000..097ff44 --- /dev/null +++ b/Back/.vscode/tasks.json @@ -0,0 +1,41 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/skydiveLogs-api/skydiveLogs-api.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/skydiveLogs-api/skydiveLogs-api.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "watch", + "command": "dotnet", + "type": "process", + "args": [ + "watch", + "run", + "--project", + "${workspaceFolder}/skydiveLogs-api/skydiveLogs-api.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/Back/skydiveLogs-api.Domain/skydiveLogs-api.Domain.csproj b/Back/skydiveLogs-api.Domain/skydiveLogs-api.Domain.csproj index 46a0374..db21197 100644 --- a/Back/skydiveLogs-api.Domain/skydiveLogs-api.Domain.csproj +++ b/Back/skydiveLogs-api.Domain/skydiveLogs-api.Domain.csproj @@ -1,8 +1,8 @@ - - - - net5.0 - skydiveLogs_api.Domain - - - + + + + net6.0 + skydiveLogs_api.Domain + + + diff --git a/Back/skydiveLogs-api.DomainBusiness/skydiveLogs-api.DomainBusiness.csproj b/Back/skydiveLogs-api.DomainBusiness/skydiveLogs-api.DomainBusiness.csproj index fd52fdb..e389a13 100644 --- a/Back/skydiveLogs-api.DomainBusiness/skydiveLogs-api.DomainBusiness.csproj +++ b/Back/skydiveLogs-api.DomainBusiness/skydiveLogs-api.DomainBusiness.csproj @@ -1,7 +1,7 @@  - net5.0 + net6.0 skydiveLogs_api.DomainBusiness diff --git a/Back/skydiveLogs-api.DomainService/skydiveLogs-api.DomainService.csproj b/Back/skydiveLogs-api.DomainService/skydiveLogs-api.DomainService.csproj index 1cd6930..c28dbac 100644 --- a/Back/skydiveLogs-api.DomainService/skydiveLogs-api.DomainService.csproj +++ b/Back/skydiveLogs-api.DomainService/skydiveLogs-api.DomainService.csproj @@ -1,12 +1,12 @@ - - - - net5.0 - skydiveLogs_api.DomainService - - - - - - - + + + + net6.0 + skydiveLogs_api.DomainService + + + + + + + diff --git a/Back/skydiveLogs-api.Infrastructure/skydiveLogs-api.Infrastructure.csproj b/Back/skydiveLogs-api.Infrastructure/skydiveLogs-api.Infrastructure.csproj index 07aa2d5..391b48d 100644 --- a/Back/skydiveLogs-api.Infrastructure/skydiveLogs-api.Infrastructure.csproj +++ b/Back/skydiveLogs-api.Infrastructure/skydiveLogs-api.Infrastructure.csproj @@ -1,17 +1,17 @@ - - - - net5.0 - skydiveLogs_api.Infrastructure - - - - - - - - - - - - + + + + net6.0 + skydiveLogs_api.Infrastructure + + + + + + + + + + + + diff --git a/Back/skydiveLogs-api.Ioc/skydiveLogs-api.Ioc.csproj b/Back/skydiveLogs-api.Ioc/skydiveLogs-api.Ioc.csproj index 4656617..46b3090 100644 --- a/Back/skydiveLogs-api.Ioc/skydiveLogs-api.Ioc.csproj +++ b/Back/skydiveLogs-api.Ioc/skydiveLogs-api.Ioc.csproj @@ -1,26 +1,19 @@ - - - - net5.0 - skydiveLogs_api.Ioc - - - - - - - - - - - - - - ..\..\..\..\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.extensions.configuration.abstractions\2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.Abstractions.dll - - - ..\..\..\..\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.extensions.dependencyinjection.abstractions\2.2.0\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll - - - - + + + + net6.0 + skydiveLogs_api.Ioc + + + + + + + + + + + + + + diff --git a/Back/skydiveLogs-api/Startup.cs b/Back/skydiveLogs-api/Startup.cs index 1705257..930803e 100644 --- a/Back/skydiveLogs-api/Startup.cs +++ b/Back/skydiveLogs-api/Startup.cs @@ -1,129 +1,129 @@ -using Microsoft.AspNetCore.Authentication.JwtBearer; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.IdentityModel.Tokens; -using skydiveLogs_api.DomainBusiness.Interfaces; -using skydiveLogs_api.Ioc; -using skydiveLogs_api.Settings; -using System.IO; -using System.Text; - -namespace skydiveLogs_api -{ - public class Startup - { - #region Public Constructors - - public Startup(IConfiguration configuration) - { - Configuration = configuration; - } - - #endregion Public Constructors - - #region Public Methods - - // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) - { - if (env.EnvironmentName == "Development") - { - app.UseDeveloperExceptionPage(); - } - else - { - // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. - app.UseHsts(); - } - - app.UseCors(); - app.UseAuthentication(); - - app.UseMvc(); - } - - // This method gets called by the runtime. Use this method to add services to the container. - public void ConfigureServices(IServiceCollection services) - { - services.AddMvc(options => { options.EnableEndpointRouting = false; }) - .SetCompatibilityVersion(CompatibilityVersion.Version_3_0); - - services.AddHttpContextAccessor(); - - // JWT - var jwtSection = Configuration.GetSection("JWT"); - services.Configure(jwtSection); - - var jwtSettings = new JwtSettings(); - jwtSection.Bind(jwtSettings); - - services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) - .AddJwtBearer(options => - { - options.SaveToken = true; - options.TokenValidationParameters = new TokenValidationParameters() - { - ValidateIssuer = true, - ValidateAudience = true, - ValidateLifetime = true, - ValidateIssuerSigningKey = true, - ValidIssuer = jwtSettings.Issuer, - ValidAudience = jwtSettings.Issuer, - IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwtSettings.Passphrase)) - }; - }); - - // CORS - var corsSettings = new CorsSettings(); - Configuration.GetSection("Cors").Bind(corsSettings); - - services.AddCors(options => - { - options.AddDefaultPolicy( - builder => - { - builder.WithOrigins(corsSettings.FrontUrl) - .AllowAnyHeader() - .AllowAnyMethod(); - }); - }); - - // IoC - var iocService = new IocService(services, Configuration); - iocService.Configure(); - - // AutoMapper - services.AddAutoMapper(typeof(Mapper.ModelProfile)); - - CheckAndInitDb(services); - } - - #endregion Public Methods - - #region Private Methods - - private void CheckAndInitDb(IServiceCollection services) - { - string connectionString = Configuration.GetConnectionString("DefaultConnection"); - string dbFile = connectionString.Replace("Filename=", string.Empty); - - if (!File.Exists(dbFile)) - { - var serviceProvider = services.BuildServiceProvider(); - var initDbService = serviceProvider.GetRequiredService(); - initDbService.GenerateDb(); - } - } - - #endregion Private Methods - - #region Public Properties - - public IConfiguration Configuration { get; } - - #endregion Public Properties - } +using Microsoft.AspNetCore.Authentication.JwtBearer; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.IdentityModel.Tokens; +using skydiveLogs_api.DomainBusiness.Interfaces; +using skydiveLogs_api.Ioc; +using skydiveLogs_api.Settings; +using System.IO; +using System.Text; + +namespace skydiveLogs_api +{ + public class Startup + { + #region Public Constructors + + public Startup(IConfiguration configuration) + { + Configuration = configuration; + } + + #endregion Public Constructors + + #region Public Methods + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + if (env.EnvironmentName == "Development") + { + app.UseDeveloperExceptionPage(); + } + else + { + // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. + app.UseHsts(); + } + + app.UseCors(); + app.UseAuthentication(); + + app.UseMvc(); + } + + // This method gets called by the runtime. Use this method to add services to the container. + public void ConfigureServices(IServiceCollection services) + { + services.AddMvc(options => { options.EnableEndpointRouting = false; }); + //.SetCompatibilityVersion(CompatibilityVersion.Version_3_0); + + services.AddHttpContextAccessor(); + + // JWT + var jwtSection = Configuration.GetSection("JWT"); + services.Configure(jwtSection); + + var jwtSettings = new JwtSettings(); + jwtSection.Bind(jwtSettings); + + services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) + .AddJwtBearer(options => + { + options.SaveToken = true; + options.TokenValidationParameters = new TokenValidationParameters() + { + ValidateIssuer = true, + ValidateAudience = true, + ValidateLifetime = true, + ValidateIssuerSigningKey = true, + ValidIssuer = jwtSettings.Issuer, + ValidAudience = jwtSettings.Issuer, + IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwtSettings.Passphrase)) + }; + }); + + // CORS + var corsSettings = new CorsSettings(); + Configuration.GetSection("Cors").Bind(corsSettings); + + services.AddCors(options => + { + options.AddDefaultPolicy( + builder => + { + builder.WithOrigins(corsSettings.FrontUrl) + .AllowAnyHeader() + .AllowAnyMethod(); + }); + }); + + // IoC + var iocService = new IocService(services, Configuration); + iocService.Configure(); + + // AutoMapper + services.AddAutoMapper(typeof(Mapper.ModelProfile)); + + CheckAndInitDb(services); + } + + #endregion Public Methods + + #region Private Methods + + private void CheckAndInitDb(IServiceCollection services) + { + string connectionString = Configuration.GetConnectionString("DefaultConnection"); + string dbFile = connectionString.Replace("Filename=", string.Empty); + + if (!File.Exists(dbFile)) + { + var serviceProvider = services.BuildServiceProvider(); + var initDbService = serviceProvider.GetRequiredService(); + initDbService.GenerateDb(); + } + } + + #endregion Private Methods + + #region Public Properties + + public IConfiguration Configuration { get; } + + #endregion Public Properties + } } \ No newline at end of file diff --git a/Back/skydiveLogs-api/skydiveLogs-api.csproj b/Back/skydiveLogs-api/skydiveLogs-api.csproj index 8100da7..37e990b 100644 --- a/Back/skydiveLogs-api/skydiveLogs-api.csproj +++ b/Back/skydiveLogs-api/skydiveLogs-api.csproj @@ -1,34 +1,34 @@ - - - - net5.0 - InProcess - skydiveLogs_api - 9d7d268e-ee4d-43a2-a9b7-5b00b516f6f8 - - - - - - - - - Never - - - - - - - - - - - - - - - - - - + + + + net6.0 + InProcess + skydiveLogs_api + 9d7d268e-ee4d-43a2-a9b7-5b00b516f6f8 + + + + + + + + + Never + + + + + + + + + + + + + + + + + + diff --git a/Back/skydiveLogs-api/skydiveLogs-api.csproj.user b/Back/skydiveLogs-api/skydiveLogs-api.csproj.user index 3cf951a..ba355f0 100644 --- a/Back/skydiveLogs-api/skydiveLogs-api.csproj.user +++ b/Back/skydiveLogs-api/skydiveLogs-api.csproj.user @@ -1,19 +1,19 @@ - - - - ApiControllerWithActionsScaffolder - root/Controller - 600 - True - False - True - - False - FolderProfile - false - skydiveLogs_api - - - ProjectDebugger - + + + + ApiControllerWithActionsScaffolder + root/Controller + 600 + True + False + True + + False + C:\Projects\SkydiveLogs\Back\skydiveLogs-api\Properties\PublishProfiles\FolderProfile.pubxml + false + skydiveLogs_api + + + ProjectDebugger + \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index f537f13..a33f279 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,29 +1,29 @@ -#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/aspnet:5.0.6-buster-slim-amd64 AS base -WORKDIR /app -EXPOSE 80 - -RUN apt-get -y update -RUN apt-get -y install nginx - -RUN mkdir /app/Front -RUN mkdir /app/API - -WORKDIR /app/Front -COPY Front/skydivelogs-app/dist . - -WORKDIR /app/API -COPY Back/dist . - -COPY start-docker.sh /start-docker.sh -RUN chmod +x /start-docker.sh - -RUN update-rc.d nginx defaults - -COPY nginx.conf /etc/nginx/sites-available/default - -VOLUME /app/API/Data -VOLUME /app/Front/config - +#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/aspnet:7.0.4-buster-slim-amd64 AS base +WORKDIR /app +EXPOSE 80 + +RUN apt-get -y update +RUN apt-get -y install nginx + +RUN mkdir /app/Front +RUN mkdir /app/API + +WORKDIR /app/Front +COPY Front/skydivelogs-app/dist . + +WORKDIR /app/API +COPY Back/dist . + +COPY start-docker.sh /start-docker.sh +RUN chmod +x /start-docker.sh + +RUN update-rc.d nginx defaults + +COPY nginx.conf /etc/nginx/sites-available/default + +VOLUME /app/API/Data +VOLUME /app/Front/config + CMD ["/start-docker.sh"] \ No newline at end of file diff --git a/doc.txt b/doc.txt index aefca0d..b6c4fd0 100644 --- a/doc.txt +++ b/doc.txt @@ -1,6 +1,6 @@ -To build an image "toto" with the version "0.1": docker build . -t skydivelogs:1.2.6 -To run ab image to container with volume : docker run -v C:\toto\logs\config:/app/Front/config -v C:\toto\logs\db:/app/API/Data -p 5080:80/tcp --name Test -it skydivelogs:0.1 - -docker save --output skydivelogs-1.2.6.tar skydivelogs:1.2.6 - -scp -P 5022 skydivelogs-1.2.6.tar administrator@51.75.68.58:~ +To build an image "toto" with the version "0.1": docker build . -t skydivelogs:1.3.2 +To run ab image to container with volume : docker run -v C:\toto\logs\config:/app/Front/config -v C:\toto\logs\db:/app/API/Data -p 5080:80/tcp --name Test -it skydivelogs:0.1 + +docker save --output skydivelogs-1.3.2.tar skydivelogs:1.3.2 + +scp -P 5022 skydivelogs-1.3.2.tar administrator@51.75.68.58:~