Docker Cache BUNDLE INSTALL not working

Does anyone know how to make BUNDLE INSTALL Cache'ing work in the latest version of DOCKER? I have tried so far:

1. 
WORKDIR /tmp 
ADD ./Gemfile Gemfile
ADD ./Gemfile.lock Gemfile.lock
RUN bundle install

2.
ADD . opt/railsapp/
WORKIDR opt/rails/app
RUN bundle install

None of them work, it still runs "BUNDE INSTALL" every time from scratch without changing the Gemfile.

Does anyone know how to properly cache for package installation?

Cheers, Andrew

+4
source share
3 answers

Each time you change a file in your local application directory, the cache will be destroyed, forcing each step to restart after that, including the last bundle install.

bundle install 2. 1, , Gemfile 1 2, -).

1 , Gemfile, , bundle , , , , .

Dockerfile:

1. 
WORKDIR /tmp 
ADD ./Gemfile Gemfile
ADD ./Gemfile.lock Gemfile.lock
RUN bundle install

2.
ADD . opt/railsapp/
WORKIDR opt/rails/app
+4

Docker 0.9.1 ADD. , Docker 0.9.1 ?

, Docker ? GitHub, ADD Docker. , Docker.

0

ADD caching is based on all file metadata, not just content.

if you are using docker builda CI-like environment with fresh validation, then it is possible that the file’s timestamps are updated, which will invalidate the cache.

0
source

Source: https://habr.com/ru/post/1543861/


All Articles