Need a Ruby and Bundler internals expert to find out why Bundler in minified Docker images can't find the bundled gems. Not implying that Bundler is broken. It works as designed. The details of its design and the failure conditions are not quite clear though :-) Looking for 'what', 'where' and 'why'. 'What' is the failure during the gem initialization process that prevents Ruby from loading the gem locations and information? 'Where' is this failure in the ruby gem initialization flow? 'Why' does this failure happen?
The minified images are created using the docker-slim tool ( [login to view URL] ).
Steps to reproduce the condition:
1. Install DockerSlim:
[login to view URL]
([login to view URL] for Mac OS X or [login to view URL] for Linux)
2. Create a Docker image for the sample Ruby app:
App code location - [login to view URL]
Create the image using the docker build command:
docker build -t my/ruby-app .
3. Minify the Docker image:
docker-slim build --http-probe my/ruby-app
Press enter when the tool prompts you.
Note the tool output… It will show you where the minification artifacts are stored:
docker-slim[build]: info=results artifacts.location=‘/.images//artifacts'
The ‘files’ subdirectory contains the files in the minified image (you can also get the files from the minified container image itself using the docker save command)
The bundled gems are in: /var/lib/gems/2.5.0/gems
4. Run the minified image:
docker run -it --rm --name="ruby_app" -p 7000:7000 my/[login to view URL]
Error message you will see from the container:
Could not find eventmachine-1.2.7 in any of the sources
You can repackage the 'minified' Docker image adding whatever instrumentation you need. The artifacts location (<path_to_your_install_dir>/.images/<hash_string>/artifacts) also contains the Dockerfile used to build the 'minified' images, so you can create a new one by hand.