This commit is contained in:
2025-10-27 17:39:18 -04:00
commit 31f723bea4
1579 changed files with 642409 additions and 0 deletions

70
Prefab.AppHost/AppHost.cs Normal file
View File

@@ -0,0 +1,70 @@
using Microsoft.Extensions.Configuration;
var builder = DistributedApplication.CreateBuilder(args);
#region Sql Server
var sqlConfig = builder.Configuration.GetSection("SqlServer");
ArgumentNullException.ThrowIfNull(sqlConfig);
var sqlPassword = builder.AddParameter("prefab-sql-password", secret: true);
var sqlContainerName = sqlConfig["ContainerName"];
ArgumentException.ThrowIfNullOrWhiteSpace(sqlContainerName);
IResourceBuilder<SqlServerServerResource> sqlServer;
var sqlServerHostPort = sqlConfig["HostPort"];
if (!string.IsNullOrWhiteSpace(sqlServerHostPort) && int.TryParse(sqlServerHostPort, out var hostPort))
{
sqlServer = builder.AddSqlServer(sqlContainerName, sqlPassword);
sqlServer.WithEndpoint("tcp", e =>
{
e.Port = hostPort; // host port (what clients connect to)
e.TargetPort = 1433; // container port (SQL Server listens on 1433)
e.IsProxied = false; // disable Aspire's reverse proxy for this endpoint
});
}
else
{
sqlServer = builder.AddSqlServer(sqlContainerName, sqlPassword);
}
var sqlServerDataVolume = sqlConfig.GetValue<bool?>("UseDataVolume");
if (sqlServerDataVolume.GetValueOrDefault(true))
{
sqlServer = sqlServer
.WithDataVolume()
.WithLifetime(ContainerLifetime.Persistent);;
}
var database = sqlServer.AddDatabase("prefab-db");
#endregion
var catalog = builder.AddProject<Projects.Prefab_Catalog_Api>("prefab-catalog")
.WithReference(database)
.WithEnvironment("ConnectionStrings__PrefabDb", database.Resource.ConnectionStringExpression)
.WithEnvironment("ConnectionStrings__PrefabDbReadOnly", database.Resource.ConnectionStringExpression)
.WaitFor(sqlServer);
var catalogClientTransport = builder.Configuration["Prefab__Catalog__Client__Transport"] ?? "InProcess";
var catalogClientBaseAddress = builder.Configuration["Prefab__Catalog__Client__BaseAddress"];
var prefabWeb = builder.AddProject<Projects.Prefab_Web>("prefab-web")
.WithReference(database)
.WithEnvironment("ConnectionStrings__PrefabDb", database.Resource.ConnectionStringExpression)
.WithEnvironment("ConnectionStrings__PrefabDbReadOnly", database.Resource.ConnectionStringExpression)
.WaitFor(sqlServer)
.WithReference(catalog)
.WaitFor(catalog);
prefabWeb.WithEnvironment("Prefab__Catalog__Client__Transport", catalogClientTransport);
if (!string.IsNullOrWhiteSpace(catalogClientBaseAddress))
{
prefabWeb.WithEnvironment("Prefab__Catalog__Client__BaseAddress", catalogClientBaseAddress);
}
builder.Build().Run();

View File

@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<Sdk Name="Aspire.AppHost.Sdk" Version="9.5.0" />
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UserSecretsId>7b0d6756-ba6a-4696-8514-2e0e767971c6</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Aspire.Hosting.AppHost" Version="9.5.1" />
<PackageReference Include="Aspire.Hosting.SqlServer" Version="9.5.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Prefab.Catalog.Api\Prefab.Catalog.Api.csproj" />
<ProjectReference Include="..\Prefab.Web\Prefab.Web.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,29 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:17039;http://localhost:15132",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21005",
"ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22057"
}
},
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:15132",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19189",
"ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20164"
}
}
}
}

View File

@@ -0,0 +1,16 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"SqlServer": {
"ContainerName": "prefab-sql",
"HostPort": 14330,
"UseDataVolume": true
},
"Parameters": {
"prefab-sql-password": "Nq7K3YR2"
}
}

View File

@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning",
"Aspire.Hosting.Dcp": "Warning"
}
}
}