Hubs-Foundation / hubs-compose

Local development setup for Hubs
Mozilla Public License 2.0
44 stars 37 forks source link

Add extra_hosts #27

Open johnshaughnessy opened 1 year ago

johnshaughnessy commented 1 year ago

For local development, we have been mapping hubs.local to localhost via entries in the hostfile (/etc/hosts). With this docker setup, the services are running in separate containers and thus should not map to localhost for cross-service traffic.

Add extra_hosts so that hubs.local and hubs-proxy.local resolve to the host-gateway and containers can reach one another. It seems that host.docker.internal also only works for me (on linux) if it is included as an extra_host.

I don't know if this is the correct solution. I was inspired by this stackoverflow answer https://stackoverflow.com/a/70725882 , which comes with a warning and recommendation to define a custom network definition that will guarantee a specific gateway address.

Incidentally, @keianhzo 's open PR defines a subnet for the hubs_network: https://github.com/mozilla/hubs-compose/pull/16/files#diff-e45e45baeda1c1e73482975a664062aa56f20c03dd9d64a827aba57775bed0d3R166-R170

Following the advice linked above, we would add a gateway: to the config (and perhaps an ip_range, if necessary).

bryanenders commented 1 year ago

This is a design smell. hubs.local and hubs-proxy.local are external host names. It tells us that our software is attempting to communicate across the WAN instead of the LAN. Let’s figure out why and determine whether or not it should be that way before hacking the hosts file.

It’s also on my todo list to make hubs.local and hubs-proxy.local a piece of configuration in Reticulum. Unfortunately they are hard-coded throughout at present.