Deploy an app from Cloud Source Repositories to App Engine
This quickstart describes how to deploy an app from Cloud Source Repositories to App Engine. In the steps that follow, you deploy your app, update the app's code and the repository, and redeploy the updated code.
Before you begin
- Complete the steps from
Create a code repository in Cloud Source Repositories.
After you complete that quickstart, you have an app you can deploy to App Engine.
- Enable the App Engine Admin API.
Deploy your app
In a terminal window, go to the directory containing the repository:
cd hello-world
Deploy the sample app:
gcloud app deploy app.yaml
Verify that your app is running:
gcloud app browse
The browser displays the message
Hello, World!
.
Update your app
In a terminal window, use a text editor to update the
main.py
file by pasting the following code:#!/usr/bin/env python import webapp2 class MainHandler(webapp2.RequestHandler): def get(self): self.response.write('Goodbye, Moon!') app = webapp2.WSGIApplication([ ('/', MainHandler) ], debug=True)
Add the file so Git can commit it:
git add main.py
Commit the file with a comment describing the history of this action:
git commit -m "Update main.py to say Goodbye Moon"
Push the file to Cloud Source Repositories:
git push origin master
Redeploy your app
In a terminal window, enter the following command:
gcloud app deploy app.yaml
Open your app:
gcloud app browse
The browser displays the message
Goodbye, Moon!
.
Clean up
To avoid incurring charges to your Google Cloud account for the resources used on this page, follow these steps.
Disable your app
In the Google Cloud console, go to the App Engine Settings page.
Click Disable application and follow the instructions.
Disabling your app takes effect immediately.
Confirm that your app is disabled by visiting the URL of your app, for example,
http://[YOUR_PROJECT_ID].appspot.com/
, where[YOUR_PROJECT_ID]
is the name of your Google Cloud project ID. If your app is disabled, an HTTP404 Not Found
status code is returned.
Delete the repository
In the GCP Console, open the All repositories page for Cloud Source Repositories.
Hold the pointer over the repository you want to delete and click Settings settings.
The General settings page opens.
Click Delete this repository delete.
The Remove repository dialog opens.
Type the name of the repository you want to delete.
Click Delete.
What's next
- Learn more about App Engine.