defang icon indicating copy to clipboard operation
defang copied to clipboard

Specify domain with port/ingress definition

Open raphaeltm opened this issue 1 year ago • 2 comments

At the moment we specify domains with the domainname field in a service definition.

I would prefer to specify the domain in the port list. Something along the lines of:

services:
  web:
    # [...]
    ports:
      - target: 3000
        mode: ingress
        host: mydomain.com

While less common, this provides the ability to specify multiple domains for a service (i.e. with an admin endpoint and a public endpoint):

services:
  twoEndpointService:
    # [...]
    ports:
      # public endpoint
      - target: 3000
        mode: ingress
        host: mydomain.com
      # public endpoint
      - target: 3003
        mode: ingress
        host: admin.mydomain.com

I think it also just feels more appropriate to define the domain along with the port. They're intrinsically tied together, so their configuration should reflect that.

raphaeltm avatar Mar 07 '24 22:03 raphaeltm

The spec has no such option though: https://github.com/compose-spec/compose-spec/blob/master/05-services.md#long-syntax-3

lionello avatar Mar 08 '24 00:03 lionello

The spec has no such option though: https://github.com/compose-spec/compose-spec/blob/master/05-services.md#long-syntax-3

@edwardrf said he could find a way to make it happen 😁

I'm guessing it would look more like:

services:
  twoEndpointService:
    # [...]
    ports:
      # public endpoint
      - target: 3000
        mode: ingress
        x-host: mydomain.com
      # public endpoint
      - target: 3003
        mode: ingress
        x-host: admin.mydomain.com

raphaeltm avatar Mar 08 '24 03:03 raphaeltm