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

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

问题描述

我有一个maven spring-boot项目部署在我正在使用以下构建器映像使用Google Cloud Build构建和部署的appengine上:解决方案

您无法将存储桶安装到构建中,但是您可以在构建结束时将.M2目录复制到存储桶中,然后还原它在后续构建的开始.

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

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']

当将此策略与并发构建混合使用时,请当心.

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天全站免登陆