如何将持久存储连接到 Google Cloud Build? [英] How to connect persistent storage to Google Cloud Build?

查看:40
本文介绍了如何将持久存储连接到 Google Cloud Build?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 appengine 上部署了一个 maven spring-boot 项目,我正在使用 Google Cloud Build 使用以下构建器映像构建和部署该项目:https://github.com/strudeau/mvn-gcloud-builder

执行构建时,大部分时间都花在从 maven 下载插件和依赖项上.我希望能够将持久卷挂载到这个 Docker 映像,以便能够保留一个持久的 .M2 目录,我的插件和依赖项将被存储,以避免每次我下载它们进行构建.

Google Cloud Filestore 可能是理想的选择,如果不是因为您必须预置 1TB 或更多的数据,这对于小型非生产利润项目来说变得非常昂贵.p>

  • 有没有办法将存储桶作为文件系统挂载到 docker 映像上?
  • 我可以挂载 Google Persistent Disk 吗?

解决方案

您不能将存储桶挂载到构建中,但您可以将 .M2 目录复制到最后的存储桶中构建,然后在后续构建开始时恢复它.

我直接从 文档,以防它消失.

步骤:- 名称:gcr.io/cloud-builders/gsutil参数:['cp','gs://mybucket/results.zip','previous_results.zip']# 使用 previous_results.zip 并生成 new_results.zip 的操作- 名称:gcr.io/cloud-builders/gsutil参数:['cp','new_results.zip','gs://mybucket/results.zip']

将此策略与并发构建混合使用时要小心.

I have a maven spring-boot project deployed on appengine that I am building and deploying using Google Cloud Build using the following builder image: https://github.com/strudeau/mvn-gcloud-builder

When performing a build, most of the time is spent downloading the plugins and dependencies from maven. I would like to be able to mount a persistent volume to this Docker image so as to be able to keep a persistent .M2 directory where my plugins and dependencies would be stored to avoid having them downloaded each time I do a build.

Google Cloud Filestore would probably be ideal if it weren't for the fact that you have to provision 1TB of data or more which becomes ridiculously expensive for a small non-production profit project.

  • Is there a way to mount a bucket as a filesystem on the docker image?
  • Can I mount a Google Persistent Disk?

解决方案

You can't mount a bucket into the build, but you can copy your .M2 directory out to a bucket at the end of a build, then restore it at the beginning of a subsequent build.

I've lifted the example directly from the documentation, in case it disappears.

steps:
- name: gcr.io/cloud-builders/gsutil
  args: ['cp', 'gs://mybucket/results.zip', 'previous_results.zip']
# operations that use previous_results.zip and produce new_results.zip
- name: gcr.io/cloud-builders/gsutil
  args: ['cp', 'new_results.zip', 'gs://mybucket/results.zip']

Watch out when mixing this strategy with concurrent builds.

这篇关于如何将持久存储连接到 Google Cloud Build?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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