The Ruby 2.5 runtime allows you to run your app in App Engine in a sandbox environment. This document explains the details of the Ruby 2.5 runtime environment, including what headers are provided to your code and other information to successfully deploy your application on App Engine.
Specify the Ruby 2.5 runtime for App Engine in the standard
environment in the
app.yaml file as
The Ruby 2.5 runtime environment uses the latest stable release of Ruby 2.5. App Engine automatically updates to new minor revisions upon deployment, but will not automatically update the major version.
For example, your application might be deployed at Ruby 2.5.0 and automatically updated to version 2.5.1 at a later deployment, but it will not be automatically updated to Ruby 2.6.
For more information on declaring and managing dependencies, see Specifying dependencies.
The runtime starts your application using the
entrypoint defined in
app.yaml. The entrypoint should start a process that
responds to HTTP requests on the port defined by the environment variable
entrypoint: bundle exec rails server -p $PORT
You must add the server as a dependency in your application's
configuration file. The runtime will install all dependencies before your
entrypoint is called.
source "https://rubygems.org" gem "rack" gem "puma"
An example entrypoint using puma for a Rails application:
entrypoint: bundle exec rails server Puma -p $PORT
An example entrypoint using puma for any Rack application:
entrypoint: bundle exec rackup -s Puma -p $PORT
For applications that can handle requests without a Rack server, you can just execute a ruby script:
entrypoint: bundle exec ruby app.rb
The following environment variables are set by the runtime:
||The ID of your App Engine application. This ID is prefixed with 'region code~' such as 'e~' for applications deployed in Europe.|
||The ID of the current deployment.|
||The App Engine environment. Set to
||The ID of the instance on which your service is currently running.|
||The amount of memory available to the application process, in MB.|
||The runtime specified in your
||The service name specified in your
||The current version label of your service.|
||The GCP project ID associated with your application.|
||The port that receives HTTP requests.|
define additional environment variables in your
but the above values cannot be overridden, except for
HTTPS and forwarding proxies
App Engine terminates HTTPS connections at the load balancer and
forwards requests to your application. Some applications need to determine
the original request IP and protocol. The user's IP address is available in
X-Forwarded-For header. Applications that require this
information should configure their web framework to trust the proxy.
The runtime includes a writable
/tmp directory, with all other directories
having read-only access. Writing to
/tmp takes up system memory. For more
information, see the
Each instance of your application can use the App Engine metadata server to query information about the instance and your project.
You can access the metadata server through the following endpoints:
The following table lists the endpoints where you can make HTTP requests for specific metadata:
||The project number assigned to your project.|
||The project ID assigned to your project.|
||The zone the instance is running in.|
||The default service account email assigned to your project.|
||Lists all the default service accounts for your project.|
||Lists all the supported scopes for the default service accounts.|
||Returns the auth token that can be used to authenticate your application to other Google Cloud APIs.|
For example, to retrieve your project ID, send a request to