Thursday, 28 September 2017

Building is so GAE

Summary

Learn to use Google Container Builder to deploy to Google App Engine instead.   It can use the same triggers for when to build, but then uses Cloud Builders to execute `gcloud` commands to deploy.


cloudbuild.yaml

The file contents are painfully simple with only a single step:
steps:
# Deploy to GAE: https://cloud.google.com/appengine/docs/standard/python/tools/uploadinganapp
- name: 'gcr.io/cloud-builders/gcloud'
  args: ['app', 'deploy', '--project', '<YOUR PROJECT ID>', '--version', '<SOME VERSION>]

Put these contents into a file called "cloudbuild.yaml" in your project somewhere.  If you only have 1 "service" being provided, then the project root makes sense.  Otherwise, you can put a different cloudbuild.yaml file in each Service folder so that it will deploy different Versions depending  on what git repo branch triggers the build.

Lastly, set up a build trigger to kick off a build when code is pushed to your project's repo.

IAM Permissions

The catch though is to make sure Container Builder has permissions to modify your Google AppEngine App.

Go to the "IAM & admin" page on the Google Cloud Console and search for "cloudbuild" which will show you which service account is being used to with Container Builder.

Change the user's roles to include AppEngine Deployer and also AppEngine Service Admin.