Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Put gems in host 'vendor/bundle' #66

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

travisdock
Copy link
Contributor

@travisdock travisdock commented Sep 9, 2023

Hi Nick,

I asked you in a previous PR if you had considered putting gems on the host so that you don't have to rebuild your containers and bundle install all gems every time you add a new one. I made a quick example of how this might work. I am still learning about your setup so I am not sure this is the best solution but it works.

In order to test it you can add the BUNDLE_PATH variable from .env.example and remove your previously built images. Then run docker compose up --build and you should see the gems install as the web container starts up. They are installed into the vendor/bundle folder locally. Visit localhost:8000 to make sure everything is working and then go back to your project and add any gem to your Gemfile. You can restart the containers or you can exec into the web container and bundle install. The new gem will be installed locally, no need to rebuild anything. But if you do need to rebuild a container the gems will still be there ready to use without running bundle again.

Note: One side effect of this method that I don't quite understand is that I am now forced to use bundle exec anywhere I wish to use one of the installed gems. I know this is because I am no longer installing gems in the default path but for the life of me I cannot get it to recognize my new path. Adding to GEM_HOME and GEM_PATHS didn't seem to help but perhaps I am misunderstanding how those work.

Also, you mentioned in the PR where I brought up this idea:

a volume mount works at the cost of mounting a lot of files back to your host.

Could you explain what that cost is? My thought was that it would be a gain to store more files on the host rather than have large images that take more time to upload and download.

This is more of an idea PR to get your thoughts. If you are considering merging it and you want me to polish it up or make any changes let me know! Feel free to close it as well if it doesn't suit your fancy.

@travisdock travisdock force-pushed the host-gems branch 2 times, most recently from b387e08 to cd1f22c Compare September 9, 2023 04:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant