Grocery
Grocery

Reputation: 2274

Docker and Rails environments

Just starting with this whole Docker thing and I can't wrap my head around one thing:

How does one deal with different dependencies? Let's say in production I don't want to have git, grunt, etc installed, but in development I do.

There's a difference between a container that can run tests, and container that runs in production.

Am I thinking about this wrong?

Upvotes: 0

Views: 252

Answers (2)

kross
kross

Reputation: 3753

docker-rails is a project I just created to make rails with docker (and CI) very easy. I think it can help you and reduce the amount of configuration necessary to get up and running with rails on docker. It deals with multiple environments i.e. development | test | production in one docker-rails.yml file, which is really just a meta configuration/inheritance wrapper over the standard docker-compose.yml.

It will allow you to run a test command set in test, vs development server, or a production setup with different containers. The example in the readme shows elasticsearch used in dev and test, but not staging or production.

I hope that helps.

Upvotes: 0

Eli
Eli

Reputation: 38899

There are different philosophies on this, but personally, I use Docker to match my production environment as closely as possible so testing with that container anywhere let's me be pretty sure things will just work once I deploy to prod. This is one of the major benefits of Docker-- that you can mimic OS, environment, dependencies, versions, etc... locally before deploying anywhere.

There's nothing wrong with having a separate container development container with added dependencies that you can pass around your team, but to me the main benefit of Docker for development is the ability to test on that simulated prod environment and run the exact same container locally that you will be using in prod once you're ready. No more "but it worked on my machine!" bugs.

Upvotes: 2

Related Questions