Compose: Rails Docs: Adding gems without rebuilding

Created on 4 May 2016  路  1Comment  路  Source: docker/compose

I've been trying out docker-compose with Rails, using the example from the docker rails documentation, and I notice that every time I add a new gem to the project I have to rebuild using docker-compose build. It's pretty annoying because it takes a while to re-download all the gems. Is this standard behavior? Is there a way to get around this?

Ideally I'd like docker-compose up to run a bash terminal instead of attempting to start the server, that way I can start the server manually from within the shell and also run any other commands I need to in the shell. This would allow me to not have rebuild every time I add a gem to the project.

Most helpful comment

First, you have to remove the bundle install from your Dockerfile
Then you have to make a volume and mount it somewhere like /bundle and tell bundler to install gems there with e.g. BUNDLE_PATH=/bundle in your docker-compose.yml

This way all your gems will live outside your app container.

There's quite a handful of posts on the internet that explain this particular setup in details

>All comments

First, you have to remove the bundle install from your Dockerfile
Then you have to make a volume and mount it somewhere like /bundle and tell bundler to install gems there with e.g. BUNDLE_PATH=/bundle in your docker-compose.yml

This way all your gems will live outside your app container.

There's quite a handful of posts on the internet that explain this particular setup in details

Was this page helpful?
0 / 5 - 0 ratings