Skip to content

Commit

Permalink
(#239) Add Aspire
Browse files Browse the repository at this point in the history
  • Loading branch information
phongnguyend committed Jun 20, 2024
1 parent 63a056e commit 9f68df8
Show file tree
Hide file tree
Showing 15 changed files with 126 additions and 34 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/.net-build-modularmonolith.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ jobs:
uses: actions/setup-dotnet@v1
with:
dotnet-version: 8.0.100


- name: Install Aspire
run: dotnet workload install aspire

- name: Build
run: dotnet build --configuration Release

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsAspireHost>true</IsAspireHost>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspire.Hosting.AppHost" Version="8.0.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ClassifiedAds.BackgroundServer\ClassifiedAds.BackgroundServer.csproj" />
<ProjectReference Include="..\ClassifiedAds.Migrator\ClassifiedAds.Migrator.csproj" />
<ProjectReference Include="..\ClassifiedAds.WebAPI\ClassifiedAds.WebAPI.csproj" />
</ItemGroup>

</Project>
10 changes: 10 additions & 0 deletions src/ModularMonolith/ClassifiedAds.AspireAppHost/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
var builder = DistributedApplication.CreateBuilder(args);

var migrator = builder.AddProject<Projects.ClassifiedAds_Migrator>("ClassifiedAds-Migrator");
var background = builder.AddProject<Projects.ClassifiedAds_BackgroundServer>("ClassifiedAds-BackgroundServer");
var webApi = builder.AddProject<Projects.ClassifiedAds_WebAPI>("ClassifiedAds-WebAPI");

var identityServer = builder
.AddExecutable("ClassifiedAds-IdentityServer", "dotnet", "../../IdentityServer/IdentityServer4/ClassifiedAds.IdentityServer", "run", $"--urls=https://localhost:44367");

builder.Build().Run();
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:17063;http://localhost:15113",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21052",
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22034"
}
},
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:15113",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19194",
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20061"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
11 changes: 4 additions & 7 deletions src/ModularMonolith/ClassifiedAds.BackgroundServer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,20 @@ COPY ./ClassifiedAds.CrossCuttingConcerns/*.csproj ./ClassifiedAds.CrossCuttingC
COPY ./ClassifiedAds.Domain/*.csproj ./ClassifiedAds.Domain/
COPY ./ClassifiedAds.Infrastructure/*.csproj ./ClassifiedAds.Infrastructure/

RUN dotnet restore ./ClassifiedAds.Application/ClassifiedAds.Application.csproj
RUN dotnet restore ./ClassifiedAds.Infrastructure/ClassifiedAds.Infrastructure.csproj

COPY ./ClassifiedAds.Contracts/*.csproj ./ClassifiedAds.Contracts/
COPY ./ClassifiedAds.Modules.AuditLog/*.csproj ./ClassifiedAds.Modules.AuditLog/
COPY ./ClassifiedAds.Modules.Configuration/*.csproj ./ClassifiedAds.Modules.Configuration/
COPY ./ClassifiedAds.Modules.Identity/*.csproj ./ClassifiedAds.Modules.Identity/
COPY ./ClassifiedAds.Modules.Notification/*.csproj ./ClassifiedAds.Modules.Notification/
COPY ./ClassifiedAds.Modules.Product/*.csproj ./ClassifiedAds.Modules.Product/
COPY ./ClassifiedAds.Modules.Product.EndToEndTests/*.csproj ./ClassifiedAds.Modules.Product.EndToEndTests/
COPY ./ClassifiedAds.Modules.Product.IntegrationTests/*.csproj ./ClassifiedAds.Modules.Product.IntegrationTests/
COPY ./ClassifiedAds.Modules.Product.UnitTests/*.csproj ./ClassifiedAds.Modules.Product.UnitTests/
COPY ./ClassifiedAds.Modules.Storage/*.csproj ./ClassifiedAds.Modules.Storage/

COPY ./ClassifiedAds.BackgroundServer/*.csproj ./ClassifiedAds.BackgroundServer/
COPY ./ClassifiedAds.Migrator/*.csproj ./ClassifiedAds.Migrator/
COPY ./ClassifiedAds.WebAPI/*.csproj ./ClassifiedAds.WebAPI/

COPY ./ClassifiedAds.ModularMonolith.sln .
RUN dotnet restore
RUN dotnet restore ./ClassifiedAds.BackgroundServer/ClassifiedAds.BackgroundServer.csproj

# Copy everything else and build
COPY . ./
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"profiles": {
"ClassifiedAds.BackgroundServer": {
"commandName": "Project",
"dotnetRunMessages": "true",
"dotnetRunMessages": true,
"environmentVariables": {
"DOTNET_ENVIRONMENT": "Development"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@ public static IServiceCollection AddClassifiedAdsOpenTelemetry(this IServiceColl
return services;
}

var resourceBuilder = ResourceBuilder.CreateDefault().AddService(options.ServiceName);

services.AddOpenTelemetry()
.ConfigureResource(configureResource =>
{
configureResource.AddService(
serviceName: options.ServiceName,
serviceVersion: Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? "unknown",
serviceInstanceId: Environment.MachineName);
serviceInstanceId: options.ServiceName + "-" + Environment.MachineName);
})
.WithTracing(builder =>
{
Expand Down
11 changes: 4 additions & 7 deletions src/ModularMonolith/ClassifiedAds.Migrator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,20 @@ COPY ./ClassifiedAds.CrossCuttingConcerns/*.csproj ./ClassifiedAds.CrossCuttingC
COPY ./ClassifiedAds.Domain/*.csproj ./ClassifiedAds.Domain/
COPY ./ClassifiedAds.Infrastructure/*.csproj ./ClassifiedAds.Infrastructure/

RUN dotnet restore ./ClassifiedAds.Application/ClassifiedAds.Application.csproj
RUN dotnet restore ./ClassifiedAds.Infrastructure/ClassifiedAds.Infrastructure.csproj

COPY ./ClassifiedAds.Contracts/*.csproj ./ClassifiedAds.Contracts/
COPY ./ClassifiedAds.Modules.AuditLog/*.csproj ./ClassifiedAds.Modules.AuditLog/
COPY ./ClassifiedAds.Modules.Configuration/*.csproj ./ClassifiedAds.Modules.Configuration/
COPY ./ClassifiedAds.Modules.Identity/*.csproj ./ClassifiedAds.Modules.Identity/
COPY ./ClassifiedAds.Modules.Notification/*.csproj ./ClassifiedAds.Modules.Notification/
COPY ./ClassifiedAds.Modules.Product/*.csproj ./ClassifiedAds.Modules.Product/
COPY ./ClassifiedAds.Modules.Product.EndToEndTests/*.csproj ./ClassifiedAds.Modules.Product.EndToEndTests/
COPY ./ClassifiedAds.Modules.Product.IntegrationTests/*.csproj ./ClassifiedAds.Modules.Product.IntegrationTests/
COPY ./ClassifiedAds.Modules.Product.UnitTests/*.csproj ./ClassifiedAds.Modules.Product.UnitTests/
COPY ./ClassifiedAds.Modules.Storage/*.csproj ./ClassifiedAds.Modules.Storage/

COPY ./ClassifiedAds.BackgroundServer/*.csproj ./ClassifiedAds.BackgroundServer/
COPY ./ClassifiedAds.Migrator/*.csproj ./ClassifiedAds.Migrator/
COPY ./ClassifiedAds.WebAPI/*.csproj ./ClassifiedAds.WebAPI/

COPY ./ClassifiedAds.ModularMonolith.sln .
RUN dotnet restore
RUN dotnet restore ./ClassifiedAds.Migrator/ClassifiedAds.Migrator.csproj

# Copy everything else and build
COPY . ./
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"ClassifiedAds.Migrator": {
"https": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:5001;http://localhost:5000"
"applicationUrl": "https://localhost:44380"
}
}
}
7 changes: 7 additions & 0 deletions src/ModularMonolith/ClassifiedAds.ModularMonolith.sln
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClassifiedAds.Contracts", "
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Contracts", "Contracts", "{F7978955-2598-49D1-BB01-293F061004F1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClassifiedAds.AspireAppHost", "ClassifiedAds.AspireAppHost\ClassifiedAds.AspireAppHost.csproj", "{F836AAB2-BB6D-4725-BD4D-36E425BA7AB7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -131,6 +133,10 @@ Global
{00E6AFF5-98AA-4302-A33D-E3E4B9D15504}.Debug|Any CPU.Build.0 = Debug|Any CPU
{00E6AFF5-98AA-4302-A33D-E3E4B9D15504}.Release|Any CPU.ActiveCfg = Release|Any CPU
{00E6AFF5-98AA-4302-A33D-E3E4B9D15504}.Release|Any CPU.Build.0 = Release|Any CPU
{F836AAB2-BB6D-4725-BD4D-36E425BA7AB7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F836AAB2-BB6D-4725-BD4D-36E425BA7AB7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F836AAB2-BB6D-4725-BD4D-36E425BA7AB7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F836AAB2-BB6D-4725-BD4D-36E425BA7AB7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -159,6 +165,7 @@ Global
{B556F32D-D996-4296-9075-E7E2E2F4B8C3} = {ECEF010F-6A7B-4418-83FF-1BEBA02A7F96}
{ECEF010F-6A7B-4418-83FF-1BEBA02A7F96} = {38967FEA-2C16-4297-8028-1B83DC14AC3F}
{00E6AFF5-98AA-4302-A33D-E3E4B9D15504} = {F7978955-2598-49D1-BB01-293F061004F1}
{F836AAB2-BB6D-4725-BD4D-36E425BA7AB7} = {62A1AB08-A2DB-404F-B073-0F89CA780F45}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A2C23354-4AAD-41AC-9E06-0A6F210ACEEF}
Expand Down
11 changes: 4 additions & 7 deletions src/ModularMonolith/ClassifiedAds.WebAPI/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,20 @@ COPY ./ClassifiedAds.CrossCuttingConcerns/*.csproj ./ClassifiedAds.CrossCuttingC
COPY ./ClassifiedAds.Domain/*.csproj ./ClassifiedAds.Domain/
COPY ./ClassifiedAds.Infrastructure/*.csproj ./ClassifiedAds.Infrastructure/

RUN dotnet restore ./ClassifiedAds.Application/ClassifiedAds.Application.csproj
RUN dotnet restore ./ClassifiedAds.Infrastructure/ClassifiedAds.Infrastructure.csproj

COPY ./ClassifiedAds.Contracts/*.csproj ./ClassifiedAds.Contracts/
COPY ./ClassifiedAds.Modules.AuditLog/*.csproj ./ClassifiedAds.Modules.AuditLog/
COPY ./ClassifiedAds.Modules.Configuration/*.csproj ./ClassifiedAds.Modules.Configuration/
COPY ./ClassifiedAds.Modules.Identity/*.csproj ./ClassifiedAds.Modules.Identity/
COPY ./ClassifiedAds.Modules.Notification/*.csproj ./ClassifiedAds.Modules.Notification/
COPY ./ClassifiedAds.Modules.Product/*.csproj ./ClassifiedAds.Modules.Product/
COPY ./ClassifiedAds.Modules.Product.EndToEndTests/*.csproj ./ClassifiedAds.Modules.Product.EndToEndTests/
COPY ./ClassifiedAds.Modules.Product.IntegrationTests/*.csproj ./ClassifiedAds.Modules.Product.IntegrationTests/
COPY ./ClassifiedAds.Modules.Product.UnitTests/*.csproj ./ClassifiedAds.Modules.Product.UnitTests/
COPY ./ClassifiedAds.Modules.Storage/*.csproj ./ClassifiedAds.Modules.Storage/

COPY ./ClassifiedAds.BackgroundServer/*.csproj ./ClassifiedAds.BackgroundServer/
COPY ./ClassifiedAds.Migrator/*.csproj ./ClassifiedAds.Migrator/
COPY ./ClassifiedAds.WebAPI/*.csproj ./ClassifiedAds.WebAPI/

COPY ./ClassifiedAds.ModularMonolith.sln .
RUN dotnet restore
RUN dotnet restore ./ClassifiedAds.WebAPI/ClassifiedAds.WebAPI.csproj

# Copy everything else and build
COPY . ./
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"ClassifiedAds.WebAPI": {
"https": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "api/values",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:5001;http://localhost:5000"
"applicationUrl": "https://localhost:44312"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
"Default": "Information",
"System": "Warning",
"Microsoft": "Warning"
},
"OpenTelemetry": {
"IsEnabled": true,
"ServiceName": "ClassifiedAds.WebAPI",
"Otlp": {
"Endpoint": "https://localhost:21052"
}
}
},
"Monitoring": {
"OpenTelemetry": {
"IsEnabled": true,
"ServiceName": "ClassifiedAds.WebAPI",
"Otlp": {
"IsEnabled": true,
"Endpoint": "https://localhost:21052"
}
}
}
}

0 comments on commit 9f68df8

Please sign in to comment.