I'm deploying a vanilla Rails 6 app to the App Engine Standard Ruby 2.5 runtime on Google Cloud.
I'm having trouble figuring out how successfully provide the RAILS_MASTER_KEY environment variable so Rails can decrypt my encrypted credentials for connecting the the database etc.
I don't want to put the RAILS_MASTER_KEY in app.yaml, and I don't want to have to include the master.key file in every deploy. As you may know, the RAILS_MASTER_KEY environment variable must be set before Rails is started, so loading it from inside my app is not an option.
In my Rails apps on App Engine Flex, I've been using Runtime Config and the rcloadenv gem by having this in my app.yaml: entrypoint:
bundle exec rcloadenv secrets -- bin/rails s
But when I do the same on App Engine Standard, I get the this error:
A 2019-08-23T11:47:45.986319Z /srv/vendor/bundle/ruby/2.5.0/bin/rcloadenv:23:in `load'
A 2019-08-23T11:47:45.986308Z LoadError: cannot load such file -- /srv/vendor/bundle/ruby/2.5.0/gems/rcloadenv-0.2.0/bin/rcloadenv
A 2019-08-23T11:47:45.986247Z bundler: failed to load command: rcloadenv (/srv/vendor/bundle/ruby/2.5.0/bin/rcloadenv)
I see that the getting started document recommends using Metadata server and the google-cloud-env gem, but I don't see anything built into that gem to make it load the metadata as environment variables.
Any pointers on how I, on App Engine Standard for Ruby 2.5:
1) Can get the rcloadenv gem to work?
2) Or can get the google-cloud-env gem to load metadata into environment variables?
3) Or can safely store and access the RAILS_MASTER_KEY in another way that Rails 6 supports?
It is permission error to read the file in the gem release 0.2.0 itself. Workaround is to install rcloadenv directly from GitHub, you can do it by replacing gem in gemfile with this line:
gem "rcloadenv", git: 'https://github.com/GoogleCloudPlatform/rcloadenv', branch: 'master', glob: 'ruby/*.gemspec'
Workaround using metadata will not work in AppEngine Standard.