mirror of
https://github.com/fiodarsazanavets/aspire-13-examples.git
synced 2026-06-20 12:23:14 +00:00
62 lines
1.7 KiB
C#
62 lines
1.7 KiB
C#
using Microsoft.Extensions.Hosting;
|
|
using OnlineShop.AppHost.Extensions;
|
|
using OnlineShop.MailDev.Hosting;
|
|
|
|
var builder = DistributedApplication.CreateBuilder(args);
|
|
|
|
var maildev = builder.AddMailDev("maildev");
|
|
|
|
var idp = builder.AddKeycloakContainer(
|
|
"idp", tag: "23.0")
|
|
.ImportRealms("Keycloak")
|
|
.WithExternalHttpEndpoints();
|
|
|
|
var cache = builder.AddRedis("cache");
|
|
|
|
var postgres = builder.AddPostgres("postgres")
|
|
.WithLifetime(ContainerLifetime.Persistent);
|
|
var postgresdb = postgres.AddDatabase("postgresdb");
|
|
|
|
var apiService = builder.AddProject<Projects.OnlineShop_ApiService>("apiservice")
|
|
.WithHttpHealthCheck("/health")
|
|
.WithReference(idp)
|
|
.WaitFor(idp)
|
|
.WaitFor(postgresdb)
|
|
.WithReference(postgresdb);
|
|
|
|
var webFrontend = builder
|
|
.AddProject<Projects.OnlineShop_Web>("webfrontend")
|
|
.WithExternalHttpEndpoints()
|
|
.WithHttpHealthCheck("/health")
|
|
.WithReference(apiService)
|
|
.WaitFor(apiService)
|
|
.WithReference(idp, env: "Identity__ClientSecret")
|
|
.WaitFor(idp)
|
|
.WithReference(cache)
|
|
.WaitFor(cache);
|
|
|
|
if (builder.Environment.IsDevelopment())
|
|
{
|
|
var webAppHttp = webFrontend.GetEndpoint("http");
|
|
var webAppHttps = webFrontend.GetEndpoint("https");
|
|
|
|
idp.WithEnvironment("WEBAPP_HTTP", () =>
|
|
$"{webAppHttp.Scheme}://{webAppHttp.Host}:{webAppHttp.Port}");
|
|
|
|
if (webAppHttps.Exists)
|
|
{
|
|
idp.WithEnvironment("WEBAPP_HTTP_CONTAINERHOST",
|
|
webAppHttps);
|
|
idp.WithEnvironment("WEBAPP_HTTPS", () =>
|
|
$"{webAppHttps.Scheme}://{webAppHttps.Host}:{webAppHttps.Port}");
|
|
}
|
|
else
|
|
{
|
|
idp.WithEnvironment("WEBAPP_HTTP_CONTAINERHOST",
|
|
webAppHttp);
|
|
}
|
|
}
|
|
|
|
|
|
builder.Build().Run();
|