I tried deploying the same Python app on Heroku, AWS Beanstalk, and Azure, and wondered if I could do the same on Google Cloud Platform. However, it was overwhelmingly complicated compared to other services. I had a lot of trouble with linking with GitHub, but in the end I found that it was very easy to do, so I will describe the details here.
--There is a Python application that has been confirmed to work locally or on other PaaS, IaaS, etc. --The above app is on the GitHub repository --You have a Google Cloud Platform account
At first, I decided to deploy it manually from local without linking with GitHub. <a href=https://cloud.google.com/appengine/docs/standard/python3/quickstart?hl=ja> As per the official tutorial , install the Google Cloud SDK and gcloud app deploy from the command line Deploy with. At first, it didn't work because there was no app.yaml, or even after adding app.yaml, the application name of entrypoint was main instead of app, and an error occurred, but that can be resolved quickly. It was. (It took me a while to find the error log.)
Next, I will try to link with GitHub, but if you first google on the net, there will be a way to link with GitHub using Google Cloud Run and Google Cloud Build. This didn't work. For the time being, if I create a Cloud Run service and create a Cloud Build trigger that works with GitHub, the trigger works properly every time I push, and it deploys normally, but even if I open the web page on App Engine Not reflected at all ,? ?? ?? Will be. I wasn't sure what Cloud Run was, so I didn't realize it was running separately from App Engine. When I was looking at the service details page of Cloud Run, I noticed that there was a link called URL, and when I clicked on it, a page that reflected the contents of the latest GitHub repository was displayed. Oh, I finally understand that.
In conclusion, it was all written in the official documentation. I didn't need Cloud Run from the beginning. https://cloud.google.com/source-repositories/docs/quickstart-triggering-builds-with-source-repositories?hl=ja
All you need
Allow integration with GAE in Cloud Build settings,
Add cloudbuild.yaml, which describes the configuration information for deploying with Cloud Build, to the project.
Create a build trigger and specify the cloudbuid.yaml created above in [Build Configuration]-[Cloud Build Configuration File].
Now every time you push to the GitHub repository, it will be automatically deployed to App Engine. Why didn't you reach this page from the beginning?
If you want to run the source on GitHub, you only need Cloud Run and Cloud Build, right? The question arises. What is App Engine for? If you use it with the same image as other Paas, is it App Engine and Cloud Build? I don't know how to use it properly.
Recommended Posts