|
| 1 | +#:sdk Aspire.AppHost.Sdk@13.0.0 |
| 2 | + |
| 3 | +var builder = DistributedApplication.CreateBuilder(args); |
| 4 | + |
| 5 | +// Add the postgres database from Dockerfile |
| 6 | +var postgres = builder.AddDockerfile("postgres-techempower", "../../../docker/postgres-techempower") |
| 7 | + .WithEndpoint(port: 5432, targetPort: 5432, name: "tcp") |
| 8 | + .WithEnvironment("POSTGRES_USER", "benchmarkdbuser") |
| 9 | + .WithEnvironment("POSTGRES_PASSWORD", "benchmarkdbpass") |
| 10 | + .WithEnvironment("POSTGRES_DB", "hello_world"); |
| 11 | + |
| 12 | +var postgresEndpoint = postgres.GetEndpoint("tcp"); |
| 13 | +var connectionString = ReferenceExpression.Create($"Server={postgresEndpoint.Property(EndpointProperty.Host)};Port={postgresEndpoint.Property(EndpointProperty.Port)};Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass"); |
| 14 | + |
| 15 | +// Add all TechEmpower benchmark applications |
| 16 | +// Note: BlazorSSR, Minimal, Mvc only support net8.0. MvcFull targets .NET Framework 4.8. |
| 17 | +// PlatformBenchmarks and RazorPages support net8.0;net9.0 multi-targeting. |
| 18 | + |
| 19 | +builder.AddProject("blazorssr", "BlazorSSR/BlazorSSR.csproj") |
| 20 | + .WaitFor(postgres) |
| 21 | + .WithEnvironment("ConnectionString", connectionString) |
| 22 | + .WithUrls(context => |
| 23 | + { |
| 24 | + var http = context.GetEndpoint("http"); |
| 25 | + if (http is not null) |
| 26 | + { |
| 27 | + context.Urls.Add(new() { Url = $"{http.Url}/plaintext", DisplayText = "plaintext" }); |
| 28 | + context.Urls.Add(new() { Url = $"{http.Url}/json", DisplayText = "json" }); |
| 29 | + context.Urls.Add(new() { Url = $"{http.Url}/fortunes", DisplayText = "fortunes" }); |
| 30 | + context.Urls.Add(new() { Url = $"{http.Url}/updates/20", DisplayText = "updates" }); |
| 31 | + } |
| 32 | + }); |
| 33 | + |
| 34 | +builder.AddProject("minimal", "Minimal/Minimal.csproj") |
| 35 | + .WaitFor(postgres) |
| 36 | + .WithEnvironment("ConnectionString", connectionString) |
| 37 | + .WithUrls(context => |
| 38 | + { |
| 39 | + var http = context.GetEndpoint("http"); |
| 40 | + if (http is not null) |
| 41 | + { |
| 42 | + context.Urls.Add(new() { Url = $"{http.Url}/plaintext", DisplayText = "plaintext" }); |
| 43 | + context.Urls.Add(new() { Url = $"{http.Url}/json", DisplayText = "json" }); |
| 44 | + context.Urls.Add(new() { Url = $"{http.Url}/fortunes", DisplayText = "fortunes" }); |
| 45 | + context.Urls.Add(new() { Url = $"{http.Url}/updates/20", DisplayText = "updates" }); |
| 46 | + } |
| 47 | + }); |
| 48 | + |
| 49 | +builder.AddProject("mvc", "Mvc/Mvc.csproj") |
| 50 | + .WaitFor(postgres) |
| 51 | + .WithEnvironment("ConnectionString", connectionString) |
| 52 | + .WithUrls(context => |
| 53 | + { |
| 54 | + var http = context.GetEndpoint("http"); |
| 55 | + if (http is not null) |
| 56 | + { |
| 57 | + context.Urls.Add(new() { Url = $"{http.Url}/plaintext", DisplayText = "plaintext" }); |
| 58 | + context.Urls.Add(new() { Url = $"{http.Url}/json", DisplayText = "json" }); |
| 59 | + context.Urls.Add(new() { Url = $"{http.Url}/fortunes", DisplayText = "fortunes" }); |
| 60 | + context.Urls.Add(new() { Url = $"{http.Url}/updates/20", DisplayText = "updates" }); |
| 61 | + } |
| 62 | + }); |
| 63 | + |
| 64 | +builder.AddProject("platformbenchmarks", "PlatformBenchmarks/PlatformBenchmarks.csproj") |
| 65 | + .WaitFor(postgres) |
| 66 | + .WithEnvironment("ConnectionString", connectionString) |
| 67 | + .WithArgs("--framework", "net9.0") |
| 68 | + .WithArgs("-p:IsDatabase=true") |
| 69 | + .WithEnvironment("DATABASE", "PostgreSql") |
| 70 | + .WithUrls(context => |
| 71 | + { |
| 72 | + var http = context.GetEndpoint("http"); |
| 73 | + if (http is not null) |
| 74 | + { |
| 75 | + context.Urls.Add(new() { Url = $"{http.Url}/plaintext", DisplayText = "plaintext" }); |
| 76 | + context.Urls.Add(new() { Url = $"{http.Url}/json", DisplayText = "json" }); |
| 77 | + context.Urls.Add(new() { Url = $"{http.Url}/fortunes", DisplayText = "fortunes" }); |
| 78 | + context.Urls.Add(new() { Url = $"{http.Url}/updates/20", DisplayText = "updates" }); |
| 79 | + } |
| 80 | + }); |
| 81 | + |
| 82 | +builder.AddProject("razorpages", "RazorPages/RazorPages.csproj") |
| 83 | + .WaitFor(postgres) |
| 84 | + .WithEnvironment("ConnectionString", connectionString) |
| 85 | + .WithArgs("--framework", "net9.0") |
| 86 | + .WithUrls(context => |
| 87 | + { |
| 88 | + var http = context.GetEndpoint("http"); |
| 89 | + if (http is not null) |
| 90 | + { |
| 91 | + context.Urls.Add(new() { Url = $"{http.Url}/plaintext", DisplayText = "plaintext" }); |
| 92 | + context.Urls.Add(new() { Url = $"{http.Url}/json", DisplayText = "json" }); |
| 93 | + context.Urls.Add(new() { Url = $"{http.Url}/fortunes", DisplayText = "fortunes" }); |
| 94 | + context.Urls.Add(new() { Url = $"{http.Url}/updates/20", DisplayText = "updates" }); |
| 95 | + } |
| 96 | + }); |
| 97 | + |
| 98 | +builder.Build().Run(); |
0 commit comments