'Deploy django to GAE standard from cloud build

I run following bash commands from my local machine to deploy django project to App engine.

python manage.py migrate
python manage.py collectstatic --noinput
gsutil rsync -R static/ gs://xyz4/static
gcloud config set project project_name_1
gcloud app deploy --quiet

I would like to set it up on cloud build. I have enabled PUSH triggers on cloud build. Need help in creating cloudbuild.yaml file



Solution 1:[1]

Cloud Build support to run on custom VPC with worker pools.

You can create a worker pool to access resources in VPC. If you will access when building you must click "Assign external IPs" in your worker pool settings and you mus use below code in your cloudbuild yaml:

options: 
  pool:
    name: "projects/${PROJECT_ID}/locations/${_REGION}/workerPools/${_WORKER_POOL}"

substitutions:
  _REGION: 'your_region'
  _WORKER_POOL: 'your_pool_name'

If you need to know your outbound ip you can access it from Cloud Nat and if you have firewall rules for outbound you have to assign a dedicated ip.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1