dotnet / tye

Tye is a tool that makes developing, testing, and deploying microservices and distributed applications easier. Project Tye includes a local orchestrator to make developing microservices easier and the ability to deploy microservices to Kubernetes with minimal configuration.
MIT License
5.29k stars 520 forks source link

Add ability to use network aliases #1492

Open dziedrius opened 1 year ago

dziedrius commented 1 year ago

What should we add or change to make your life better?

Docker compose has ability to add network aliases like this:

tests.mock.proxy:
    container_name: tests.mock.proxy
    image: nginx
    networks:
      default:
        aliases:
          - api.to-be.mocked.com
          - orders.local.domain.com

meaning, that I can access my services by DNS names - which might serve at least couple purposes:

Why is this important to you?

Currently we have two configs - docker-compose and tye just because we can't fully control host names in tye and we need that for our integration tests, as we need to mock out several third party APIs.

davidfowl commented 1 year ago

Can you share your nginx config as well? Are you doing host name routing to other local services that mock out those APIs?

dziedrius commented 1 year ago

Sure, currently used nginx config looks something like this:

server {    
    listen 443 ssl;

    ssl_certificate     /etc/nginx/certs/server.crt;
    ssl_certificate_key /etc/nginx/certs/server.key;

    location / {
        proxy_pass http://host.docker.internal:5055;
    }
}

Where host.docker.internal:5055 is WireMock server running in tests and pretending to be one or another mocked API. We're using self signed certificate, which we trust in other containers.

Currently we're not using routing to other local services, but that is due the fact, that for development locally we use tye for it's faster startup/easier debugging and docker-compose only for integration tests due to ability to do network aliases. If tye would support network aliases, I think we would use routing to local services too, as we like to have same url schema as in prod (hence in IIS we use host names too - like api.local.domain.com).