I'm using Google Cloud Builder (GCB) to build some Node.js code. I'm using npm's new package-lock.json
feature to pin dependencies. This works best when using the npm ci
command that was introduced in [email protected]
. Unfortunately, all of GCB's npm images are currently set to [email protected]
How can I use a different npm version in GCB without creating a custom builder image?
Edit: It may not be the case that all of GCB's images are set to [email protected]
, but the one that I need to use (node-8.11.0
) is set to this version.
I solved the issue by creating my own container image based on the cloud-builder's npm image.
Dockerfile:
cloudbuild.yaml:
I ran
gcloud builds submit . --config=cloudbuild.yaml
from the same folder containing theDockerfile
andcloudbuild.yaml
files. This submitted the build to GCB and posted an image in my project's container registry. I then used this image in my other project'scloudbuild.yaml
that needed the upgraded npm version, like so:After doing this, everything works as expected.