Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google cloud build - custom machine type

I'm using the Google Cloud Build service to create images of my application. I created a build trigger that looks for a git tag in a specific format. Each time that Cloud Build detects a new tag, a new build is performed.

Since the build time is pretty long, I am trying to make it faster.

I found that it's possible to ask Google to build the application on a faster machine (Source).

gcloud builds submit --config=cloudbuild.yaml --machine-type=n1-highcpu-8 .

This code works if you choose the manual build option. Since I created the build trigger from the GCP user interface, I can't find any place to define the machine-type argument.

How can I choose the machine-type on automatic build triggers?

UPDATE:

In the Trigger window, I chose Build Configuration=Docker File and this is my docker file preview:

docker build \
    -t gcr.io/PROJ_NAME/APP_NAME/$TAG_NAME:$COMMIT_SHA \
    -f deployments/docker/APPNAME.docker \
    .

How should my buildconfig.yaml file look like?

like image 437
No1Lives4Ever Avatar asked Sep 02 '26 01:09

No1Lives4Ever


1 Answers

You need to change to Build Configuration=Cloud Build configuration file, and commit the cloudbuild.yaml to git.

Then use the machineType field in the options property of your cloudbuild.yaml file.

E.g


steps:
- name: 'gcr.io/cloud-builders/docker'
  args: ['build', '-t', 'gcr.io/PROJ_NAME/APP_NAME/$TAG_NAME:$COMMIT_SHA', '-f', 'deployments/docker/APPNAME.docker', '.']
options:
 machineType: 'N1_HIGHCPU_8'
like image 83
Rich Avatar answered Sep 05 '26 02:09

Rich