Skip to content

Instantly share code, notes, and snippets.

@slovely
Last active May 20, 2025 15:29
Show Gist options
  • Select an option

  • Save slovely/37cee8c8e758cfba0c58796be6d5aea9 to your computer and use it in GitHub Desktop.

Select an option

Save slovely/37cee8c8e758cfba0c58796be6d5aea9 to your computer and use it in GitHub Desktop.
Aspire
// in the app host:
// Has a database that I can reference with EF no issue
var db = builder.AddPostgres("db").AddDatabase("db");
// Custom dockerfile which has an app running on container port 8080
var svc = builder.AddDockerfile( "svc", "./", "./Dockerfile")
.WithEndpoint(0, 8080, "http", "http")
;
var backend = builder.AddProject<MyProject>("backend")
.WithReference(db)
.WithReference(svc.GetEndpoint("http"))
.WaitFor(db)
;
// Then inside the "MyProject" startup I have this:
builder.Services.AddHttpClient<ITheService, TheService>(static client => client.BaseAddress = new Uri("http://svc"));
// but when I use that, I get
// HttpRequestException: Name or service not known (svc:80)
@davidfowl
Copy link

// in the app host:

// Has a database that I can reference with EF no issue
var db = builder.AddPostgres("db").AddDatabase("db");

// Custom dockerfile which has an app running on container port 8080
var svc = builder.AddDockerfile( "svc", "./", "./Dockerfile")
        .WithHttpEndpoint(targetPort: 8080);

var backend = builder.AddProject<MyProject>("backend")
        .WithReference(db)
        //.WithReferenceRelationship(binservice)
        .WithReference(binservice.GetEndpoint("http"))
        .WaitFor(db)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment