DEV Community

Discussion on: Using Docker in development the right way

 
gianiaz profile image
Giovanni Lenoci • Edited

If you have many microfrontend in prod I assume each one will be accessible on a different hostname.

You can do the same on a local machine mapping local host in your /etc/hosts (or similar under windows), host 127.0.0.1 -> 127.0.0.254 will map to localhost:

127.0.0.2 microfrontend1.app
127.0.0.3 microfrontend2.app
Enter fullscreen mode Exit fullscreen mode

In your docker-compose file you can expose every microfrontend in this way:

node1:
  ports:
    - "127.0.0.2:80:8080" #

node2:
  ports:
    - "127.0.0.3:80:8080" #
Enter fullscreen mode Exit fullscreen mode

node1 will respond to microfrontend1.app in your local browser and node2 to microfrontend2.app

In this configuration you take rid of limits about port already used because there are 2 different hosts.

Hope this helps

Thread Thread
 
klvenky profile image
Venkatesh KL

That makes sense. Thanks a ton 👏

Thread Thread
 
klvenky profile image
Venkatesh KL

Only difference is that we're having a proxy service at the top level which hides all the micro apps from external world. So that's something that is have to consider while trying it out.
I'll give it a shot thanks for the motivation 👏