docker - 当 docker build 运行 Dockerfile 时使用来自 bitbucket 的节点缓存依赖项
问题描述
我正在尝试使用来自 bitbucket 的自定义缓存依赖项,使用 Dockerfile。
这是我的bitbucket-pipelines.yml
:
hml:
- step:
caches:
- node-cache
name: Tests and build
services:
- docker
volumes:
- "$BITBUCKET_CLONE_DIR/node_modules:/root/node_modules"
- "$BITBUCKET_CLONE_DIR:/code"
script:
# - apt update
# - apt-get install -y curl
# - curl -L "https://github.com/docker/compose/releases/download/1.25.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
# - chmod +x /usr/local/bin/docker-compose
# - echo 'DIALOGFLOW_PROJECT_ID=a' > .env
# - docker-compose up -d
# - docker exec api npm run test
- docker image inspect $(docker image ls -aq) --format {{.Size}} | awk '{totalSizeInBytes += $0} END {print totalSizeInBytes}'
- echo $BITBUCKET_CLONE_DIR/node_modules
- docker build -t cloudia/api .
- docker save --output api.docker cloudia/api
artifacts:
- api.docker
- step:
name: Deploy
services:
- docker
deployment: staging
script:
- apt-get update
- apt-get install -y curl unzip python jq
- curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
- mv awscli-bundle.zip /tmp/awscli-bundle.zip
- unzip /tmp/awscli-bundle.zip -d /tmp
- /tmp/awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
- docker load --input ./api.docker
- chmod +x ./deploy_hml.sh
- ./deploy_hml.sh
definitions:
caches:
node-cache: node_modules
services:
docker:
memory: 2048
这是我的Dockerfile
:
FROM node:10.15.3
WORKDIR /code
# Using some comments for tests
COPY [ "package*.json", "/code/" ]
RUN npm install --silent
COPY . /code
RUN npm run build
EXPOSE 5000
CMD npm start
我的管道运行没有问题,但缓存不起作用。
当我尝试运行管道时收到的消息:
Cache "node-cache": Downloading
Cache "node-cache": Not found
当 docker build 运行 Dockerfile 时,如何设置管道?
解决方案
推荐阅读
- javascript - 如何在边缘浏览器中通过 javascript 覆盖文本文件?
- c# - Unity:在不移动子游戏对象的情况下更改 UI 游戏对象父级和位置
- reactjs - React:搜索框和过滤地图
- python - Python3.8 - FastAPI 和无服务器 (AWS Lambda) - 无法处理发送到 api 端点的文件
- javascript - 使用 setTimeout 制作动画,因为我想在动画上添加延迟,但它的行为很奇怪
- ios - iOS:如何在 UILabel 上的单击位置获取字符
- c++ - 为什么c ++中的函数需要指针才能工作(按值传递,按引用传递)
- python - 在python中将对象列转换为int列
- flutter - Flutter:设置初始滚动偏移水平 ListviewBuilder 取决于日期
- excel - 基于单元格的具有多个标准的 Sumifs