How to connect persistent storage to Google Cloud Build?
Asked Answered
C

1

6

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?
Cryo answered 11/8, 2018 at 15:54 Comment(1)
Did you get this sort out? If you did, how?Tracee
U
6

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.

Unsex answered 22/4, 2019 at 20:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.