我的yarn install
现在大约需要5分钟。我正在尝试找出一种减少它们的方法。
现在在我的Dockerfile中,我有以下内容:
COPY package.json yarn.lock node_modules /usr/src/app/
COPY ${YARN_CACHE} /root/.cache/yarn/
WORKDIR /usr/src/app
# We are doing this so that we can make use of layer caching
# (i.e. most likely yarn deps won't change as often as the app code)
COPY . /usr/src/app
# yarn install
RUN yarn install
在我的圈子文件中,我有
- restore_cache:
keys:
# only restores cache if the yarn file is the same
- yarn-packages-v4-{{ checksum "yarn.lock" }}
- run: docker pull "xxx.dkr.ecr.us-east-1.amazonaws.com/website:latest"
- run: docker build --build-arg NODE_ENV=production --build-arg YARN_CACHE=$(yarn cache dir) --force-rm -t xxx.dkr.ecr.us-east-1.amazonaws.com/website:build-${CIRCLE_BUILD_NUM} .
但是我的纱线安装仍然需要5分钟。我在做错什么吗?
答案 0 :(得分:2)
问题是yarn cache dir
的结果是一个外部文件夹,该外部文件夹在Docker构建中不存在或为空。您有几个选择
yarn install