worknenjoy / truppie

The marketplace for adventures
http://www.truppie.com
MIT License
51 stars 38 forks source link

Run docker as bridge mode instead of network mode #140

Open junjizhi opened 5 years ago

junjizhi commented 5 years ago

Currently docker-compose-dev.yml starts both container as network mode, it doesn't work that nice because you have to find the ip for the container to visit the new application. With bridge mode and port forwarding, you can visit http://localhost:3000 to visit the app.

Screenshot attached

N/A

How to reproduze the user scenario

alexanmtz commented 5 years ago

Merged and going to deploy @junjizhi, thanks! 🚀

alexanmtz commented 5 years ago

@junjizhi I had to undo the change in config/database.yml to allow connect to localhost if not using docker, cause db is not mapped. We need to find a way that will not affect a local env without docker

junjizhi commented 5 years ago

@alexanmtz you can edit your hosts file to point db to 127.0.0.1

alexanmtz commented 5 years ago

@junjizhi Let's try to figure out a way that don't require changes on hosts

junjizhi commented 5 years ago

localhost is just an entry in hosts to point to 127.0.0.1. If you remove that entry, your config/database.yml won't work even if it's pointing to localhost.

Pointing it to db, running the app in docker would just work. When running the app locally, they would see an db initialization error. We can document this in README. And I would expect devs are comfortable to edit hosts file.

An alternative is never run rails app in dev environment in Docker (which is super slow anyway). make a separate environment for docker and update config/database.yml. Only run dev in localhost. Having same configs for local and docker won't work unless we make the above tweaks.

alexanmtz commented 5 years ago

Yeah, I see @junjizhi , it is possible you create a pull request with this changes and I will approve this time? Including the changes on hosts?

Which OS you're using? Windows Mac or Linux?