Skip to content

introduction of BUNDLE_APP_CONFIG leads to unexpected behavior for 'statically' bundled apps #129

@MrMarvin

Description

@MrMarvin

In #69 the file based configuration for bundler was changed to a ENV based approach. This MR also adds a new configuration option for bundler: BUNDLE_APP_CONFIG, which changes how and where bundler looks for additional configuration. For example see https://github.com/docker-library/ruby/pull/69/files#diff-1578307c887a49e90a57418e653ad7f6R51

Bundlers default is:

Bundler retrieves its configuration from the local application (app/.bundle/config), environment variables, and the user's home directory (~/.bundle/config), in that order of priority.
(http://bundler.io/v1.3/man/bundle-config.1.html)

Which is imho a smart separation of project vs. global/user configuration, however in our docker based use case there really isn't a need for global bundler configuration.

With this setting set via Dockerfile ENV, we loose the ability to ship bundler configs with our apps. There are multiple ways of getting an app into the container, be it at buildtime or runtime (COPY'd, -ved or wget'ed during runtime ...) and not all necessarily include running bundle install at start up time! The main reason I noticed this behavior is because of one of my apps uses private gems that we bundle statically with bundle install --deployment. For those unfamiliar with the --deployment option, it basically does two things: 1. installs gems to a subdirectory of the project (commonly to vendor/bundle right besides the Gemfile) and 2. creates a .bundler/config file which changes the bundler path (per-project!) to the local directory the gems were just installed into.

Example of a FROM ruby:2.3 image:

root@e4477eb8fca6:/app# bundle list
Gems included by the bundle:
Could not find coderay-1.1.1 in any of the sources
root@e4477eb8fca6:/app# BUNDLE_APP_CONFIG=.bundle bundle list
Gems included by the bundle:
  * bundler (1.14.6)
  * coderay (1.1.1)
  * diff-lcs (1.3)
  * method_source (0.8.2)
  * mustermann (1.0.0)
  * pry (0.10.4)
  * puma (3.8.2)
  * rack (2.0.3)
  * rack-protection (2.0.0)
  * rack-test (0.6.3)
  * rspec (3.6.0)
  * rspec-core (3.6.0)
  * rspec-expectations (3.6.0)
  * rspec-mocks (3.6.0)
  * rspec-support (3.6.0)
  * sinatra (2.0.0)
  * slop (3.6.0)
  * tilt (2.0.7)

I am aware that one can easily change that behavior back to the default by changing the ENV when running the image, but I was wondering why we decided to change it in the first place? Pretty sure I am just missing something here and there is a good reason. cc @tianon

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionUsability question, not directly related to an error with the image

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions