GoogleCloudPlatform/cloud-build-local

[feature] Allow mounting workspace volume to a different mountpoint

Closed this issue · 3 comments

This feature would be helpful in the GCP managed version of cloudbuild as well.

Use case: a build step involves running a script that assumes a particular absolute path for the repo. Setting workspace's mountpoint to the expected path would facilitate this.

Could you expand and elaborate on your example?

Certainly. Example of a naive git-based deployment flow for a single-server web application:

  1. SSH to server
  2. cd $web_root && git pull
  3. Git post-merge hook runs, performing some light "build" tasks, which are just bash scripts. One such task calls a python script lives among the source code, outputting to some build location.

In step 3, the build script calls the python script by it's absolute path; a relative path might become invalid if the build script moves directories.

One could argue that the proper approach would be to have the build script cd to the repo root and use relative paths from there, which would relatively easy to do if you have git installed to tell you where the repo root is. Or, you could just use absolute paths, which works just fine.

If you are moving this logic to cloud build, you would need to refactor to eliminate absolute path references. If, instead, you could mount the source volume to an arbitrary directory, the code would work just as it did on the server.

Can code be written so as to avoid these concerns? Of course, but it often isn't unless there is an immediate cause to do so. Most of the web was built before the proliferation of unit tests, containerized build environments, and devops culture in general.

Close Issue as part of archive process; please see notice of archive status.