Docker Cache Bundle安装失败 [英] Docker Cache BUNDLE INSTALL not working

查看:71
本文介绍了Docker Cache Bundle安装失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都知道如何在最新的DOCKER版本中使BUNDLE INSTALL Cache'ing正常工作吗?到目前为止,我已经尝试过:

Anybody knows how to make BUNDLE INSTALL Cache'ing work in latest DOCKER release? I've 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

它们都不起作用,它每次都从头开始运行"BUNDE INSTALL",而无需更改Gemfile.

None of them work, it still runs "BUNDE INSTALL" everytime from scratch without Gemfile being changed.

任何人都知道如何使捆绑包安装的缓存正常工作吗?

Anyone knows how to make Caching for bundle install work correctly?

干杯,安德鲁

推荐答案

每次更改本地应用程序目录中的任何文件时,缓存都会被清除,并强制随后的每个步骤都重新运行,包括最后一个捆绑安装.

Each time you change any file in your local app directory, the cache will be wiped out, forcing every step afterwards to be re-run, including the last bundle install.

解决方案是不要在第2步中运行 bundle install .您已经在第1步中安装了gems,因此Gemfile在第1步和第2步之间更改的可能性很小;-)

The solution is don't run bundle install in step 2. You have already installed your gems in step 1 and there is little chance the Gemfile will change between step 1 and step 2 ;-).

第1步的重点是添加您的Gemfile,该文件不应经常更改,因此您可以在添加应用程序的其余部分之前将其和随后的bundle命令缓存起来,如果您仍然使用该文件,则更改频率可能会非常高开发它.

The whole point of step 1 is to add your Gemfile, which should not change to often, so you can cache it and the subsequent bundle command before adding the rest of your app, which will probably change very often if you are still developing it.

这是Dockerfile的样子:

Here's how the Dockerfile could look like:

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

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

这篇关于Docker Cache Bundle安装失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆