-
Notifications
You must be signed in to change notification settings - Fork 739
Description
When using aspire build -p docker-compose the following Docker Compose YAML will be generated:
services:
apiservice:
image: "${APISERVICE_IMAGE}"
environment:
OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES: "true"
OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES: "true"
OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY: "in_memory"
ASPNETCORE_FORWARDEDHEADERS_ENABLED: "true"
HTTP_PORTS: "8000"
ports:
- "8001:8000"
- "8003:8002"
networks:
- "aspire"
webfrontend:
image: "${WEBFRONTEND_IMAGE}"
environment:
OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES: "true"
OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES: "true"
OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY: "in_memory"
ASPNETCORE_FORWARDEDHEADERS_ENABLED: "true"
HTTP_PORTS: "8004"
services__apiservice__http__0: "http://apiservice:8000"
services__apiservice__https__0: "https://apiservice:8002"
ports:
- "8005:8004"
- "8007:8006"
networks:
- "aspire"
networks:
aspire:
driver: "bridge"This is the YAML file generated from the template, and hitting the weather endpoint on the front end doesn't work because the template is configured to preference the HTTPS connection. Unfortunately, in Docker Compose we don't do any TLS setup.
There are a couple of things we could do here:
- Modify the Docker Compose publisher to automatically exclude TLS endpoints.
- Give developers instructions to fine-tune their code for publish scenarios (see example):
using Aspire.Hosting.Docker;
var builder = DistributedApplication.CreateBuilder(args);
builder.AddDockerComposePublisher();
var apiService = builder.AddProject<Projects.HelloAspire_ApiService>("apiservice");
builder.AddProject<Projects.HelloAspire_Web>("webfrontend")
.WithExternalHttpEndpoints()
.WithReference(apiService.GetEndpoint("http")) // Only reference HTTP.
.WaitFor(apiService);
builder.Build().Run();