A setting that allows Cloud Build to automatically deploy Django projects to App Engine. cloudbuild.yaml I will share the setting contents because there seems to be no Japanese information.
Execute Standard deployment method + Use the following cloudbuild.yaml file.
cloudbuild.yaml
steps:
#Create an environment to run django for collectstatic
- name: 'python:3'
entrypoint: python3
args: ['-m', 'venv', '/workspace/venv']
- name: 'python:3'
entrypoint: "/workspace/venv/bin/pip"
args: ['install', '-r', 'requirements.txt']
#Collect static using the created venv (test etc. may be executed)
- name: 'python:3'
entrypoint: "/workspace/venv/bin/python"
args: ['./manage.py', 'collectstatic', '--noinput']
#Deploy to App Engine
- name: "gcr.io/cloud-builders/gcloud"
args: ["app", "deploy"]
timeout: "1200s"
At the deploy step, we create venv and run collectstatic or test there. The only caveat is that Cloud Build only takes over the information in "/ workspace /" to the next step.
With the cloudbuild.yaml settings above, you can deploy nicely.
If you do Link GitHub and Cloud Build, it will be automatically deployed every time you push to GitHub. It is recommended because it can be set to.
If you have any questions, questions, or suggestions for improvement regarding the first post, please feel free to comment.
Recommended Posts