-
Notifications
You must be signed in to change notification settings - Fork 334
Install bundle gem in the same path as the system gems are #53
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
Comments
That seems valid to me. You could just have them both use a local FROM ruby:2.2.3
ADD Gemfile* /usr/src/app/
RUN bundle install
ADD . /usr/src/app/ You'll just have to remember to rebuild when you make |
That pretty much works, however I was aiming at a simpler workflow by sparing me from using What I ended using is the same ruby image to create a data-only container, something similar to this: gems: &app_base
image: ruby:2.2.3
volumes: [ ".:/usr/src/app", "/usr/local/bundle" ]
working_dir: /usr/src/app
jobs: &app
<<: *app_base
volumes_from: [ "gems" ]
entrypoint: /usr/src/app/dev-entrypoint.sh
command: sidekiq -c 25
web:
<<: *app
command: rails s -p 3000
ports: [ "3000:3000" ] The entrypoint script runs the It would still be nice if bundler was installed in the same place as the system gems in this official image, tho. Bundler seems to be pretty ubiquitous, and almost everyone expects to be part of a somewhat default install or ruby - I know it is not the case with the official installer, but take a hint at what RVM, Rbenv and ruby-install do. |
Hey @vovimayhem, I'm trying to do something similar. Hope it's ok to jump in. My googling lead me to this post that suggests you can cache bundled gems on a data only volume, but it's not working very well for me. I think I have to build the data volume first, and then mount it in my app image. What do you think? |
@dmitrym0 I came out with this demo some weeks ago, with a workflow extremely close to what I was looking for. There's no build step involved, as you can see. I'd prefer to use a build step as a last resort if there's the need to add something else to the base image (i.e. another executable, etc), other than the app gems. |
On the other hand, I do use docker build to actually build the app image and upload it to the hub so I can deploy it to a docker host, but that's not related to my current development flow. |
Thanks @vovimayhem, that's very helpful! One question though. Do you feel that this the "Docker way"? When I started looking at docker a little while I was under the impression that it's recommended to make the containers as immutable as possible by providing all prerequisites at the build stage. Your approach relies on bundle installing the gems at container startup which could potentially mean that two containers started from the same image may (in theory) be different. What do you think? Apologies if this is a stupid question, I'm a docker newbie. |
@dmitrym0 The recommendation of making containers as immutable as possible is spot-on... for production-like setups, where no further changes will be made to a container in order for the app to run. But that particular demo was all about spinning up a development environment, in the most fluid and productive way possible... That's why I use the official images, and install gems with the entry point. While developing, I can assure you that nothing is immutable, so I wanted to avoid that build step, sparing me from filling my docker images list with mostly temporary images... and maybe spare me from problems with images not having the latest code. |
👍 |
Any further ideas on this? Still doing it with Docker-compose up? It'd be wonderful if it could work without it. |
I believe that this should be fixed, as we do
|
More specifically, it appears that #68 was the PR which made the switch. 👍 |
…into 'master' Issue/multiple add more missing people and misc fixes * Moves Francisca to L&ST section * Updates most titles * removes Matthew from past page * Adds Tom Carrol to past * Adds Jared Lang to past * Adds Shelly Cavanaugh to past * Adds Chet Bortz to past * Adds Brent Shaw to past * Adds Austin Florez to past * removes Brandon Stull from past Fixes docker-library#54 docker-library#53 docker-library#52 See merge request !30
I'm having this use case in which I bring up several containers of the same ruby (rails) app with different commands using
docker-compose
for my development enviroment:Using this image will require me to call
bundle install
on each container... but since is the same app, exactly the same gems will be installed on each container... I could mount a volume from a data-container on the/usr/local/bundle
path, so both containers use the same installed gems:...but this will wipe out the image's installed bundler, as it's installed precisely on the
/usr/local/bundle
path.How about installing bundler BEFORE setting the
$GEM_HOME
in this image'sDockerfile
? Like this:Any issues with that?
Also, does anybody has a better workflow / technique for development using this image & docker-compose?
The text was updated successfully, but these errors were encountered: