This quickstart shows you how to create a small App Engine app that displays a short message.
In the Google Cloud Console, on the project selector page, select or create a Google Cloud project.
Note: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.
Go to project selector
Make sure that billing is enabled for your Cloud project. Learn how to confirm that billing is enabled for your project.
Enable the Cloud Build API.
Enable the API
Install and initialize the Cloud SDK.
Initialize your App Engine app with your project and choose its region:
gcloud app create --project=[YOUR_PROJECT_ID]
When prompted, select the region where you want to locate your App Engine application.
Caution: You cannot change an app's region once it has been set.
Install the following prerequisites:
This quickstart demonstrates a simple Ruby app written with the Sinatra web framework that you can deploy to App Engine. Although this sample uses Sinatra, you can use other frameworks such as Ruby on Rails.
Download the Hello World app
We've created a simple Hello World app for Ruby so you can quickly get a feel for deploying an app to the Google Cloud.
Clone the Hello World sample app repository to your local machine.
git clone https://github.com/GoogleCloudPlatform/ruby-docs-samples
Alternatively, you can download the sample as a zip file and extract it.
Change to the directory that contains the sample code.
Run Hello World on your local machine
This example uses Bundler to run the Hello World app on your local computer:
If you don't already have the Ruby programming language installed, download and install Ruby.
Download and Install Ruby
gem install bundler
Install dependencies for this project:
Start a local web server.
bundle exec ruby app.rb -p 8080
In your web browser, enter:
The Hello World message from the sample app displays on the page. In your terminal window, press Ctrl+C to exit the web server.
Deploy and run Hello World on App Engine
To deploy your app to the App Engine flexible environment:
Deploy the Hello World app by running the following command from the hello_world directory:
gcloud app deploy
Learn about the optional flags.
Launch your browser to view the app at https://PROJECT_ID.REGION_ID.r.appspot.com
gcloud app browse
where PROJECT_ID represents your Google Cloud project ID.
This time, the page that displays the Hello World message is delivered by a web server running on an App Engine instance.
Congratulations! You've deployed your first Ruby app to App Engine flexible environment!
If you encountered any errors deploying your application, check the troubleshooting tips.
See the following sections for information about cleaning up as well as links to possible next steps that you can take.
To avoid incurring charges, you can delete your Cloud project to stop billing for all the resources used within that project.
Caution: Deleting a project has the following effects:
Everything in the project is deleted. If you used an existing project for this tutorial, when you delete it, you also delete any other work you've done in the project.
Custom project IDs are lost. When you created this project, you might have created a custom project ID that you want to use in the future. To preserve the URLs that use the project ID, such as an appspot.com URL, delete selected resources inside the project instead of deleting the whole project.
In the Cloud Console, go to the Manage resources page.
Go to Manage resources
In the project list, select the project that you want to delete, and then click Delete.
In the dialog, type the project ID, and then click Shut down to delete the project.
Learn the whole platform
Now that you know what it's like to develop and deploy App Engine apps, you can explore the rest of Google Cloud. You already have the Cloud SDK installed which gives you the tools to interact with products like Cloud SQL, Cloud Storage, Firestore, and more.
For a guided walkthrough that teaches you how to create an app that uses the entire platform, not just App Engine, check out our quickstart on creating the Bookshelf app.
Learn about the App Engine flexible environment
Here are some topics to help continue your learning about App Engine.
Hello World is the simplest possible App Engine app, as it contains only one service, has only one version, and all of the code is located within the app's root directory. This section describes each of the app files in detail.
The Hello World app is a basic one-file Sinatra app:
View on GitHub
get "/" do
The app.yaml file describes an app's deployment configuration:
View on GitHub
entrypoint: bundle exec ruby app.rb
# This sample incurs costs to run on the App Engine flexible environment.
# The settings below are to reduce costs during testing and are not appropriate
# for production use. For more information, see:
Here, app.yaml specifies the runtime used by the app, and sets env: flex, specifying that the app uses the flexible environment.
Gemfile is used to specify the app's RubyGem dependencies, and Bundler is used to declare and install dependencies. The Hello World app requires one Ruby gem: the Sinatra web framework:
View on GitHub