Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">

<Sdk Name="Aspire.AppHost.Sdk" Version="9.0.0" />
<Sdk Name="Aspire.AppHost.Sdk" Version="9.3.0" />

<PropertyGroup>
<OutputType>Exe</OutputType>
Expand All @@ -19,8 +19,8 @@
</ItemGroup>

<ItemGroup>
<Using Remove="*" />
<ProjectReference Include="..\Boilerplate.Server.Web\Boilerplate.Server.Web.csproj" />
<ProjectReference Include="..\Boilerplate.Server.Shared\Boilerplate.Server.Shared.csproj" IsAspireProjectResource="false" />
<ProjectReference Condition=" '$(api)' == 'Standalone' OR '$(api)' == ''" Include="..\Boilerplate.Server.Api\Boilerplate.Server.Api.csproj" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System.Linq;
using System.Threading.Tasks;
using Aspire.Hosting.ApplicationModel;

namespace Aspire.Hosting;

public static class IDistributedApplicationBuilderExtensions
{
/// <summary>
/// https://github.com/davidfowl/aspire-ai-chat-demo/blob/main/AIChat.AppHost/DashboardExtensions.cs
/// </summary>
public static void AddAspireDashboard(this IDistributedApplicationBuilder builder)
{
if (builder.ExecutionContext.IsPublishMode)
{
// The name aspire-dashboard is special cased and excluded from the default
var dashboard = builder.AddContainer("dashboard", "mcr.microsoft.com/dotnet/aspire-dashboard:9.0")
.WithHttpEndpoint(targetPort: 18888)
.WithHttpEndpoint(name: "otlp", targetPort: 18889);

builder.Eventing.Subscribe<BeforeStartEvent>((e, ct) =>
{
// We loop over all resources and set the OTLP endpoint to the dashboard
// we should make WithOtlpExporter() add an annotation so we can detect this
// automatically in the future.
foreach (var r in e.Model.Resources.OfType<IResourceWithEnvironment>())
{
if (r == dashboard.Resource)
{
continue;
}

builder.CreateResourceBuilder(r).WithEnvironment(c =>
{
c.EnvironmentVariables["OTEL_EXPORTER_OTLP_ENDPOINT"] = dashboard.GetEndpoint("otlp");
c.EnvironmentVariables["OTEL_EXPORTER_OTLP_PROTOCOL"] = "grpc";
c.EnvironmentVariables["OTEL_SERVICE_NAME"] = r.Name;
});
}

return Task.CompletedTask;
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

//#elif (database == "PostgreSql")
var postgresDatabase = builder.AddPostgres("postgresserver")
.WithPgAdmin(config => config.WithLifetime(ContainerLifetime.Persistent).WithVolume("/var/lib/pgadmin/Boilerplate/data"))
.WithLifetime(ContainerLifetime.Persistent)
.WithVolume("/var/lib/postgres-server/Boilerplate/data")
.WithImage("pgvector/pgvector", "pg17") // pgvector supports embedded vector search.
Expand All @@ -22,6 +23,7 @@
//#elif (database == "MySql")

var mySqlDatabase = builder.AddMySql("mysqlserver")
.WithPhpMyAdmin(config => config.WithLifetime(ContainerLifetime.Persistent).WithVolume("/var/lib/phpMyAdmin/Boilerplate/data"))
.WithLifetime(ContainerLifetime.Persistent)
.WithVolume("/var/lib/mySql-server/Boilerplate/data")
.AddDatabase("mysqldb");
Expand Down Expand Up @@ -81,6 +83,8 @@

//#endif

builder.AddAspireDashboard();

await builder
.Build()
.RunAsync();
Loading