Run the container, with the gem files living on the host filesystem
docker run -it --rm \
--volume "$PWD":/app \
--workdir /app \
--env "BUNDLE_PATH=.gems" \
--link "earnings-calls-database" \
soodesune/ruby-rails:2.3.1-alpine sh
Run the tests once, and then copy the gems into the container and run the tests again.
/app # bundle exec rspec
...........
Finished in 6.95 seconds (files took 1 minute 27.65 seconds to load)
11 examples, 0 failure
It took 1m 27sec to lost the files! Copy them into the container and run the test again.
/app # cp -r .gems /.gems2
/app # BUNDLE_PATH=/.gems2
/app # bundle exec rspec
...........
Finished in 0.67496 seconds (files took 3.76 seconds to load)
11 examples, 0 failure
Only ~4 seconds to load the files! The slowdow is definitly cased by pulling the gems across the host filesystem mount.
Since this is a "temporary" problem, I elected to:
--env GEM_PATH=/.fast-gems
docker exec -it THE_CONTAINER_NAME cp -r .gems /.fast-gems
I'm not bundling that much right now, so I can just repeat (2) each time. Soon this will be fixed by the docker team anyway