🐛 Fix aspire local dev issue
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using Aspire.Hosting.Yarp.Transforms;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
var builder = DistributedApplication.CreateBuilder(args);
|
||||
|
||||
var isDev = builder.Environment.IsDevelopment();
|
||||
|
||||
// Database was configured separately in each service.
|
||||
// var database = builder.AddPostgres("database");
|
||||
|
||||
@@ -9,42 +14,55 @@ var cache = builder.AddRedis("cache");
|
||||
var queue = builder.AddNats("queue").WithJetStream();
|
||||
|
||||
var ringService = builder.AddProject<Projects.DysonNetwork_Ring>("ring")
|
||||
.WithReference(queue)
|
||||
.WithHttpHealthCheck()
|
||||
.WithEndpoint(5001, 5001, "https", name: "grpc");
|
||||
.WithReference(queue);
|
||||
var passService = builder.AddProject<Projects.DysonNetwork_Pass>("pass")
|
||||
.WithReference(cache)
|
||||
.WithReference(queue)
|
||||
.WithReference(ringService)
|
||||
.WithHttpHealthCheck()
|
||||
.WithEndpoint(5001, 5001, "https", name: "grpc");
|
||||
.WithReference(ringService);
|
||||
var driveService = builder.AddProject<Projects.DysonNetwork_Drive>("drive")
|
||||
.WithReference(cache)
|
||||
.WithReference(queue)
|
||||
.WithReference(passService)
|
||||
.WithReference(ringService)
|
||||
.WithHttpHealthCheck()
|
||||
.WithEndpoint(5001, 5001, "https", name: "grpc");
|
||||
.WithReference(ringService);
|
||||
var sphereService = builder.AddProject<Projects.DysonNetwork_Sphere>("sphere")
|
||||
.WithReference(cache)
|
||||
.WithReference(queue)
|
||||
.WithReference(passService)
|
||||
.WithReference(ringService)
|
||||
.WithReference(driveService)
|
||||
.WithHttpHealthCheck()
|
||||
.WithEndpoint(5001, 5001, "https", name: "grpc");
|
||||
.WithReference(driveService);
|
||||
var developService = builder.AddProject<Projects.DysonNetwork_Develop>("develop")
|
||||
.WithReference(cache)
|
||||
.WithReference(passService)
|
||||
.WithReference(ringService)
|
||||
.WithHttpHealthCheck()
|
||||
.WithEndpoint(5001, 5001, "https", name: "grpc");
|
||||
.WithReference(ringService);
|
||||
|
||||
List<IResourceBuilder<ProjectResource>> services =
|
||||
[ringService, passService, driveService, sphereService, developService];
|
||||
|
||||
for (var idx = 0; idx < services.Count; idx++)
|
||||
{
|
||||
var service = services[idx];
|
||||
var grpcPort = 7002 + idx;
|
||||
|
||||
if (isDev)
|
||||
{
|
||||
service.WithEnvironment("GRPC_PORT", grpcPort.ToString());
|
||||
|
||||
var httpPort = 8001 + idx;
|
||||
service.WithEnvironment("HTTP_PORTS", httpPort.ToString());
|
||||
service.WithHttpEndpoint(httpPort, targetPort: null, isProxied: false, name: "http");
|
||||
}
|
||||
else
|
||||
{
|
||||
service.WithHttpEndpoint(8080, targetPort: null, isProxied: false, name: "http");
|
||||
}
|
||||
|
||||
service.WithEndpoint(isDev ? grpcPort : 7001, isDev ? null : 7001, "https", name: "grpc", isProxied: false);
|
||||
}
|
||||
|
||||
// Extra double-ended references
|
||||
ringService.WithReference(passService);
|
||||
|
||||
builder.AddYarp("gateway")
|
||||
.WithHostPort(5000)
|
||||
.WithConfiguration(yarp =>
|
||||
{
|
||||
var ringCluster = yarp.AddCluster(ringService.GetEndpoint("http"));
|
||||
@@ -75,4 +93,4 @@ builder.AddYarp("gateway")
|
||||
|
||||
builder.AddDockerComposeEnvironment("docker-compose");
|
||||
|
||||
builder.Build().Run();
|
||||
builder.Build().Run();
|
Reference in New Issue
Block a user