configure project

main
Young 6 months ago
parent e4191f9f85
commit f333f518e2

@ -0,0 +1,25 @@
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/.idea
**/*.*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

@ -2,6 +2,16 @@
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BackendTutorial", "BackendTutorial\BackendTutorial.csproj", "{3BD4328A-2EB0-4D5C-85FF-91196959D4C9}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BackendTutorial", "BackendTutorial\BackendTutorial.csproj", "{3BD4328A-2EB0-4D5C-85FF-91196959D4C9}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Infrastructure", "modules\Infrastructure\src\Infrastructure\Infrastructure.csproj", "{F6F9C651-D13D-4DEA-9698-7DD7BD739338}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Infrastructure.EventBus", "modules\Infrastructure\src\Infrastructure.EventBus\Infrastructure.EventBus.csproj", "{C5750CB0-63CB-4EAB-B74A-4433C88102A9}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{CCD3893B-24AB-4D90-94F4-189A921D297F}"
ProjectSection(SolutionItems) = preProject
docker-compose.yml = docker-compose.yml
.env = .env
EndProjectSection
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -12,5 +22,13 @@ Global
{3BD4328A-2EB0-4D5C-85FF-91196959D4C9}.Debug|Any CPU.Build.0 = Debug|Any CPU {3BD4328A-2EB0-4D5C-85FF-91196959D4C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3BD4328A-2EB0-4D5C-85FF-91196959D4C9}.Release|Any CPU.ActiveCfg = Release|Any CPU {3BD4328A-2EB0-4D5C-85FF-91196959D4C9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3BD4328A-2EB0-4D5C-85FF-91196959D4C9}.Release|Any CPU.Build.0 = Release|Any CPU {3BD4328A-2EB0-4D5C-85FF-91196959D4C9}.Release|Any CPU.Build.0 = Release|Any CPU
{F6F9C651-D13D-4DEA-9698-7DD7BD739338}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F6F9C651-D13D-4DEA-9698-7DD7BD739338}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F6F9C651-D13D-4DEA-9698-7DD7BD739338}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F6F9C651-D13D-4DEA-9698-7DD7BD739338}.Release|Any CPU.Build.0 = Release|Any CPU
{C5750CB0-63CB-4EAB-B74A-4433C88102A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C5750CB0-63CB-4EAB-B74A-4433C88102A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C5750CB0-63CB-4EAB-B74A-4433C88102A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C5750CB0-63CB-4EAB-B74A-4433C88102A9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

@ -4,11 +4,23 @@
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.10"/> <PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.10"/>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2"/> <PackageReference Include="Swashbuckle.AspNetCore" Version="6.9.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\modules\Infrastructure\src\Infrastructure.EventBus\Infrastructure.EventBus.csproj" />
<ProjectReference Include="..\modules\Infrastructure\src\Infrastructure\Infrastructure.csproj" />
</ItemGroup>
<ItemGroup>
<Content Include="..\.dockerignore">
<Link>.dockerignore</Link>
</Content>
</ItemGroup> </ItemGroup>
</Project> </Project>

@ -1,6 +0,0 @@
@BackendTutorial_HostAddress = http://localhost:5226
GET {{BackendTutorial_HostAddress}}/weatherforecast/
Accept: application/json
###

@ -0,0 +1,24 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER $APP_UID
WORKDIR /app
EXPOSE 80
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["BackendTutorial/BackendTutorial.csproj", "BackendTutorial/"]
COPY ["modules/Infrastructure/src/Infrastructure.EventBus/Infrastructure.EventBus.csproj", "modules/Infrastructure/src/Infrastructure.EventBus/"]
COPY ["modules/Infrastructure/src/Infrastructure/Infrastructure.csproj", "modules/Infrastructure/src/Infrastructure/"]
RUN dotnet restore "BackendTutorial/BackendTutorial.csproj"
COPY . .
WORKDIR "/src/BackendTutorial"
RUN dotnet build "BackendTutorial.csproj" -c $BUILD_CONFIGURATION -o /app/build
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "BackendTutorial.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "BackendTutorial.dll"]

@ -1,44 +1,8 @@
var builder = WebApplication.CreateBuilder(args); using Infrastructure.Extensions;
// Add services to the container. var builder = WebApplication.CreateBuilder(args);
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle builder.AddDefaultInfrastructure<long>();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build(); var app = builder.Build();
// Configure the HTTP request pipeline. app.UseDefaultInfrastructure();
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
var summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
app.MapGet("/weatherforecast", () =>
{
var forecast = Enumerable.Range(1, 5).Select(index =>
new WeatherForecast
(
DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
Random.Shared.Next(-20, 55),
summaries[Random.Shared.Next(summaries.Length)]
))
.ToArray();
return forecast;
})
.WithName("GetWeatherForecast")
.WithOpenApi();
app.Run();
record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)
{
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
}

@ -1,13 +1,5 @@
{ {
"$schema": "http://json.schemastore.org/launchsettings.json", "$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:41725",
"sslPort": 44310
}
},
"profiles": { "profiles": {
"http": { "http": {
"commandName": "Project", "commandName": "Project",
@ -28,14 +20,6 @@
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
} }
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
} }
} }
} }

@ -1,8 +0,0 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

@ -0,0 +1,6 @@
services:
tutorial:
image: backend-tutorial
build:
context: .
dockerfile: BackendTutorial/Dockerfile
Loading…
Cancel
Save