Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get a container to use a custom port #259

Open
codekoenig opened this issue Oct 6, 2024 · 0 comments
Open

Can't get a container to use a custom port #259

codekoenig opened this issue Oct 6, 2024 · 0 comments

Comments

@codekoenig
Copy link

codekoenig commented Oct 6, 2024

I need one service/container of my Aspire app to use a custom port (5050) instead of 8080.

I did this in the AppHost:

var builder = DistributedApplication.CreateBuilder(args);

var secondapi = builder.AddProject<Projects.SecondApi>("secondapi")
    .WithEndpoint("http", endpoint =>
    {
        endpoint.Port = 5050;
        endpoint.IsProxied = false;
    });

builder.AddProject<Projects.OtelSampleApi>("otelsampleapi")
    .WithReference(secondapi);

builder.Build().Run();

And the generated manifest after running Aspire looks like this:

  "$schema": "https://json.schemastore.org/aspire-8.0.json",
  "resources": {
    "secondapi": {
      "type": "project.v0",
      "path": "../SecondApi/SecondApi.csproj",
      "env": {
        "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": "{secondapi.bindings.http.targetPort}"
      },
      "bindings": {
        "http": {
          "scheme": "http",
          "protocol": "tcp",
          "transport": "http",
          "port": 5050
        },
        "https": {
          "scheme": "https",
          "protocol": "tcp",
          "transport": "http"
        }
      }
    },

But the built container still uses 8080.

Is there something I need to do differently to get the container to use 5050?

I'm building for Compose btw.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant