Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect persistent storage to Google Cloud Build?

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?
like image 404
simon Avatar asked Aug 11 '18 15:08

simon


1 Answers

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.

like image 107
ryanhos Avatar answered Oct 13 '22 22:10

ryanhos