Hi, this thing makes me despair...
I have an asp.net core app (service) inside a docker container. I have a docker-compose.yaml that starts this container.
Port: 9010 --> 8070 (inside docker-compose)
I use Consul for container registration and try to self-register my service. For that as I understand it, I need to know that the container is accessible from the outside via port 9010.
That means my application has to ask in its source code on which external port it is running.
For Consul registration I use:
registration = new AgentServiceRegistration()
{
ID = $"{serviceName}:{uri.Port}",
Name = $"{serviceName}",
Address = $"{uri.Host}",
Port = uri.Port // <<< This must be the external port
};
consulClient.Agent.ServiceDeregister(registration.ID).ConfigureAwait(true);
consulClient.Agent.ServiceRegister(registration).ConfigureAwait(true);
You
Thanks for help!
who does the port mapping ? the host
who has to inform the container ? the host
that's about it
docker compose up -e <service>:<env>:<value>
but i don't think that's a thing
.MapGet("some/url/structure", (string foo, int bar) => HandleRequest(foo, bar));
foo
and bar
there, can you just give it MyRequestObject
that has properties Foo
and Bar
and have it do model binding?
Result<T>
type to let you signal error results without exceptions, for cases where errors are expected and not exceptional
return Results.NotFound<User>(query.UserId);
rather than having to throw new UserNotFoundException(query.UserId);
var result = await _mediator.Send(query);
return MapToResponse(result);
that looks promising but might require consuming applications to write binders for everything