tilt icon indicating copy to clipboard operation
tilt copied to clipboard

Feature request: Setting hosts file entries (for Docker containers)

Open NanoSector opened this issue 3 years ago • 0 comments

Describe the Feature You Want

We run a bunch of services with docker-compose, but we want them to be available at specific domains for local dev environments so our authentication server can recognise the test environment. For example, dev-api.domain.tld. This will require changes at the Docker host to make the containers accessible beyond localhost.

The kubefwd extension already does something similar, but for Kubernetes. We would have to move over our docker configuration to Kubernetes for this to work.

For Vagrant the vagrant-hostsupdater plugin exists.

Ideally we would define this in the Tiltfile so all of our local environment code is isolated to Tilt and not spilled inside of Docker compose.

We currently have a Traefik container with https://github.com/zekker6/traefik-hosts-generator accompanying it. However, this makes the docker-compose setup unsuitable for deployment as it requires a specific network setup.

Current Behavior

This behaviour does not exist, but can be worked around with the use of a container combination like described above.

Why Do You Want This?

We are looking into Tilt to set up a local development environment, but our services need to be accessible at a specific hostname.

Additional context An example Tiltfile of what I'd like to see:

docker_compose('docker-compose.yml')

host('dev-api.domain.tld', '127.0.0.1')
# or
local_host('dev-api.domain.tld')

This would update /etc/hosts with

#previous hosts content

127.0.0.1     dev-api.domain.tld # possibly some identifier so Tilt knows to remove it on a tilt down

NanoSector avatar Feb 24 '22 08:02 NanoSector