Ruby on Rails App on Google App Engine

How do change from Google App Engine from Flexible Environment to Standard environment

The error on the logs you provided states:

bundler: failed to load command: rackup (/workspace/.bundle/gems/ruby/2.7.0/bin/rackup)

I can see that you're using Puma, and the App Engine Standard docs specify some steps to take for apps that depend on Rack:

Most web applications use a Rack-supported web server such as Puma,
Unicorn or Thin.

You must add the server as a dependency in your application's Gemfile
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

The instructions for flex are the same as the standard environment regarding the Gemfile and the entrypoint, so I'm not sure why one works and the other does not, but I encourage you to double-check if all those instructions are properly implemented.

I don't think there's anything inherently wrong with your app.yaml, since the API would reject the deployment if you passed a configuration that was not allowed in App Engine.

It is likely related to the entrypoint or the dependencies. This would allow building the container and deploying it, but would fail when the script actually tries to start.

Ruby on Rails app on Google App Engine

Deploying Rails on Google's App Engine has become a lot easier than it used to be. There are a couple of caveats you should be aware of:

  • App Engine only supports the Python and Java environments so for Rails you will be deploying on JRuby
  • App Engine's datastore is based on BigTable so you won't be able to use ActiveRecord on a relational database (if you want your datastore hosted in AppEngine). But as @Geoff Lanotte as pointed out there is a Datamapper adapter you can use
  • Pre-deployment testing is done within Google's sandbox tools as opposed to things like script/server

Some other resources you might consider:

http://code.google.com/p/appengine-jruby/

http://rails-primer.appspot.com/

http://gist.github.com/335023

Google App Engine asset pipeline standard environment

The problem is that the default configuration of app.yaml is preventing a crucial file being uploaded to GAE.

Specifically the skip_files section has some defaults that are preventing all dot-files from being uploaded, including the sprockets manifest file: /public/assets/.sprockets-manifest-5y483543959430890.json. Without this file, Rails assumes that assets haven't been precompiled.

You need to override the default skip_files configuration with something that doesn't prevent the sprockets manifest from being uploaded, but still blocks things like .git/*.

This is working for me now, but I'm sure it could be further refined:

skip_files:
- ^(.*/)?#.*#$
- ^(.*/)?.*~$
- ^(.*/)?.*/RCS/.*$
- ^(.*/)?\.git/.*$

proper Ruby version for Google App Engine Ruby Standard Environment w/Rails

Here's the official word from the Ruby App Engine runtime team.

If you have a Ruby version constraint in your Gemfile, always use a pessimistic version constraint (or other mechanism to allow more recent patchlevels), rather than locking to a specific patchlevel. For example, use something like ruby "~> 2.5.5" to indicate 2.5.5 or any newer patchlevel, rather than ruby "2.5.5" or ruby "2.5.7". This isn't a temporary workaround, but an actual requirement and best practice for App Engine standard.

The reason is twofold. During a rollout of a new Ruby version, there may be a short period where the bundle install is run on a different Ruby patchlevel than the app itself. This is what you ran into, and it apparently is the expected behavior because the "bundle builder" component is rolled out independently from the runtime image.

But more importantly, App Engine standard may upgrade your Ruby patchlevel at any time. Your app might be running on Ruby 2.5.6 today, but tomorrow you might find it upgraded to Ruby 2.5.7, even if you didn't redeploy explicitly. This is App Engine's intended behavior: it transparently applies critical updates and security patches, and that may include updating the patchlevel of the Ruby interpreter. (Note that App Engine only updates the Ruby patchlevel. It will never update your app from, say, Ruby 2.5 to Ruby 2.6 unless you explicitly tell it to use a Ruby 2.6 runtime.) Because of this feature, if your Gemfile specifies the Ruby version, it needs to be able to handle patchlevel updates, for example by using a pessimistic version constraint.

As a secondary note, .ruby-version is ignored on App Engine standard environment. Note this is different from App Engine flexible environment, which uses the file as a way for your app to request a specific Ruby version to run on. The standard environment, however, chooses and controls the Ruby version for you, and you don't get a say.

Apologies for the predicament. I'll work with the team to try to clarify our documentation on this.



Related Topics



Leave a reply



Submit