Compare commits
23 Commits
Author | SHA1 | Date |
---|---|---|
|
de2daa5693 | 1 year ago |
|
8f150d8db0 | 1 year ago |
|
13bb701d1d | 1 year ago |
|
8d50285de5 | 1 year ago |
|
78290912be | 1 year ago |
|
c0afc8a4a3 | 2 years ago |
|
37afa9436d | 2 years ago |
|
1402ae1b95 | 2 years ago |
|
dd0d45f131 | 2 years ago |
|
9707d2ce23 | 2 years ago |
|
5b5fbc4e29 | 2 years ago |
|
c1dbb0c469 | 2 years ago |
|
9a65aae7c1 | 2 years ago |
|
62e10a01c5 | 2 years ago |
|
043826bcaa | 2 years ago |
|
9e74449ef7 | 2 years ago |
|
72b88d04d4 | 2 years ago |
|
80a880ebdc | 2 years ago |
|
c686ee9737 | 2 years ago |
|
9792fb3325 | 2 years ago |
|
911acb9cb6 | 2 years ago |
|
3c174bf47c | 2 years ago |
|
554f254a2c | 2 years ago |
@ -1,26 +1,27 @@
|
||||
#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:6.0 AS base
|
||||
WORKDIR /app
|
||||
EXPOSE 80
|
||||
EXPOSE 443
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
|
||||
WORKDIR /src
|
||||
COPY ["API_LoL_Project/API_LoL_Project.csproj", "API_LoL_Project/"]
|
||||
COPY ["StubLib/StubLib.csproj", "StubLib/"]
|
||||
COPY ["Model/Model.csproj", "Model/"]
|
||||
COPY ["Shared/Shared.csproj", "Shared/"]
|
||||
COPY ["DTO/DTO.csproj", "DTO/"]
|
||||
RUN dotnet restore "API_LoL_Project/API_LoL_Project.csproj"
|
||||
COPY . .
|
||||
WORKDIR "/src/API_LoL_Project"
|
||||
RUN dotnet build "API_LoL_Project.csproj" -c Release -o /app/build
|
||||
|
||||
FROM build AS publish
|
||||
RUN dotnet publish "API_LoL_Project.csproj" -c Release -o /app/publish
|
||||
|
||||
FROM base AS final
|
||||
WORKDIR /app
|
||||
COPY --from=publish /app/publish .
|
||||
#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:6.0 AS base
|
||||
WORKDIR /app
|
||||
EXPOSE 80
|
||||
EXPOSE 443
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
|
||||
WORKDIR /src
|
||||
COPY ["API_LoL_Project/API_LoL_Project.csproj", "API_LoL_Project/"]
|
||||
COPY ["StubLib/StubLib.csproj", "StubLib/"]
|
||||
COPY ["Model/Model.csproj", "Model/"]
|
||||
COPY ["Shared/Shared.csproj", "Shared/"]
|
||||
COPY ["DTO/DTO.csproj", "DTO/"]
|
||||
RUN dotnet restore "API_LoL_Project/API_LoL_Project.csproj"
|
||||
COPY . .
|
||||
WORKDIR "/src/API_LoL_Project"
|
||||
RUN dotnet build "API_LoL_Project.csproj" -c Release -o /app/build
|
||||
|
||||
FROM build AS publish
|
||||
RUN dotnet publish "API_LoL_Project.csproj" -c Release -o /app/publish
|
||||
|
||||
FROM base AS final
|
||||
WORKDIR /app
|
||||
COPY --from=publish /app/publish .
|
||||
RUN ls -R
|
||||
ENTRYPOINT ["dotnet", "API_LoL_Project.dll"]
|
@ -1,108 +1,107 @@
|
||||
using Business;
|
||||
using Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.AspNetCore.Mvc.ApiExplorer;
|
||||
using Microsoft.AspNetCore.Mvc.Versioning;
|
||||
using Model;
|
||||
using StubLib;
|
||||
using API_LoL_Project;
|
||||
using API_LoL_Project.JsonConverter;
|
||||
using API_LoL_Project.Middleware.Auth;
|
||||
using Microsoft.OpenApi.Models;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
var connectionString = builder.Configuration.GetConnectionString("LolDatabase");
|
||||
builder.Services.AddDbContext<LolDbContext>(options =>
|
||||
options.UseSqlite(connectionString), ServiceLifetime.Singleton);
|
||||
|
||||
builder.Services.AddControllers().AddJsonOptions(options =>
|
||||
{
|
||||
options.JsonSerializerOptions.Converters.Add(new ReadOnlyDictionaryConverter<string, int>());
|
||||
});
|
||||
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen( cont =>
|
||||
{
|
||||
cont.AddSecurityDefinition("ApiKey", new Microsoft.OpenApi.Models.OpenApiSecurityScheme
|
||||
{
|
||||
Description = "The Key to acces to the API",
|
||||
Type = SecuritySchemeType.ApiKey,
|
||||
Name = "x-api-key",
|
||||
In = ParameterLocation.Header,
|
||||
Scheme = "ApiKeyScheme"
|
||||
});
|
||||
|
||||
var scheme = new OpenApiSecurityScheme
|
||||
{
|
||||
Reference = new OpenApiReference
|
||||
{
|
||||
Type = ReferenceType.SecurityScheme,
|
||||
Id = "ApiKey"
|
||||
},
|
||||
In = ParameterLocation.Header
|
||||
};
|
||||
|
||||
var requirement = new OpenApiSecurityRequirement
|
||||
{
|
||||
{
|
||||
scheme, new List<string>()
|
||||
}
|
||||
};
|
||||
cont.AddSecurityRequirement(requirement);
|
||||
|
||||
}
|
||||
|
||||
|
||||
);
|
||||
|
||||
builder.Services.AddApiVersioning(opt =>
|
||||
{
|
||||
opt.DefaultApiVersion = new Microsoft.AspNetCore.Mvc.ApiVersion(1, 0);
|
||||
opt.AssumeDefaultVersionWhenUnspecified = true;
|
||||
opt.ReportApiVersions = true;
|
||||
opt.ApiVersionReader = ApiVersionReader.Combine(new UrlSegmentApiVersionReader());
|
||||
});
|
||||
builder.Services.ConfigureOptions<LolSwaggerOptions>();
|
||||
builder.Services.AddVersionedApiExplorer(setup =>
|
||||
{
|
||||
setup.GroupNameFormat = "'v'VVV";
|
||||
setup.SubstituteApiVersionInUrl = true;
|
||||
});
|
||||
|
||||
|
||||
builder.Services.AddScoped<AuthMiddlewareFliter>();
|
||||
|
||||
builder.Services.AddSingleton<IDataManager, DbData>();
|
||||
//builder.Services.AddSingleton<IDataManager, StubData>();
|
||||
|
||||
var app = builder.Build();
|
||||
var apiVersionDescriptionProvider = app.Services.GetRequiredService<IApiVersionDescriptionProvider>();
|
||||
|
||||
app?.Services?.GetService<LolDbContext>()?.Database.EnsureCreated();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
/* app.UseSwaggerUI();*/
|
||||
app.UseSwaggerUI(options =>
|
||||
{
|
||||
foreach (var description in apiVersionDescriptionProvider.ApiVersionDescriptions)
|
||||
{
|
||||
options.SwaggerEndpoint($"/swagger/{description.GroupName}/swagger.json",
|
||||
description.GroupName.ToUpperInvariant());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
|
||||
app.Run();
|
||||
using Business;
|
||||
using Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.AspNetCore.Mvc.ApiExplorer;
|
||||
using Microsoft.AspNetCore.Mvc.Versioning;
|
||||
using Model;
|
||||
using StubLib;
|
||||
using API_LoL_Project;
|
||||
using API_LoL_Project.JsonConverter;
|
||||
using API_LoL_Project.Middleware.Auth;
|
||||
using Microsoft.OpenApi.Models;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
var connectionString = builder.Configuration.GetConnectionString("LolDatabase");
|
||||
builder.Services.AddDbContext<LolDbContext>(options =>
|
||||
options.UseSqlite(connectionString), ServiceLifetime.Singleton);
|
||||
|
||||
builder.Services.AddControllers().AddJsonOptions(options =>
|
||||
{
|
||||
options.JsonSerializerOptions.Converters.Add(new ReadOnlyDictionaryConverter<string, int>());
|
||||
});
|
||||
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen( cont =>
|
||||
{
|
||||
cont.AddSecurityDefinition("ApiKey", new Microsoft.OpenApi.Models.OpenApiSecurityScheme
|
||||
{
|
||||
Description = "The Key to acces to the API",
|
||||
Type = SecuritySchemeType.ApiKey,
|
||||
Name = "x-api-key",
|
||||
In = ParameterLocation.Header,
|
||||
Scheme = "ApiKeyScheme"
|
||||
});
|
||||
|
||||
var scheme = new OpenApiSecurityScheme
|
||||
{
|
||||
Reference = new OpenApiReference
|
||||
{
|
||||
Type = ReferenceType.SecurityScheme,
|
||||
Id = "ApiKey"
|
||||
},
|
||||
In = ParameterLocation.Header
|
||||
};
|
||||
|
||||
var requirement = new OpenApiSecurityRequirement
|
||||
{
|
||||
{
|
||||
scheme, new List<string>()
|
||||
}
|
||||
};
|
||||
cont.AddSecurityRequirement(requirement);
|
||||
|
||||
}
|
||||
|
||||
|
||||
);
|
||||
|
||||
builder.Services.AddApiVersioning(opt =>
|
||||
{
|
||||
opt.DefaultApiVersion = new Microsoft.AspNetCore.Mvc.ApiVersion(1, 0);
|
||||
opt.AssumeDefaultVersionWhenUnspecified = true;
|
||||
opt.ReportApiVersions = true;
|
||||
opt.ApiVersionReader = ApiVersionReader.Combine(new UrlSegmentApiVersionReader());
|
||||
});
|
||||
builder.Services.ConfigureOptions<LolSwaggerOptions>();
|
||||
builder.Services.AddVersionedApiExplorer(setup =>
|
||||
{
|
||||
setup.GroupNameFormat = "'v'VVV";
|
||||
setup.SubstituteApiVersionInUrl = true;
|
||||
});
|
||||
|
||||
|
||||
builder.Services.AddScoped<AuthMiddlewareFliter>();
|
||||
|
||||
builder.Services.AddSingleton<IDataManager, DbData>();
|
||||
//builder.Services.AddSingleton<IDataManager, StubData>();
|
||||
|
||||
var app = builder.Build();
|
||||
var apiVersionDescriptionProvider = app.Services.GetRequiredService<IApiVersionDescriptionProvider>();
|
||||
|
||||
app?.Services?.GetService<LolDbContext>()?.Database.EnsureCreated();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI(options =>
|
||||
{
|
||||
foreach (var description in apiVersionDescriptionProvider.ApiVersionDescriptions)
|
||||
{
|
||||
options.SwaggerEndpoint($"/swagger/{description.GroupName}/swagger.json",
|
||||
description.GroupName.ToUpperInvariant());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
|
||||
app.Run();
|
||||
|
After Width: | Height: | Size: 1.6 KiB |
Loading…
Reference in new issue