Code Monkey home page Code Monkey logo

appengine-ruby's Introduction

Google App Engine Integration Tools

Gem Version

This repository contains the "appengine" gem, a collection of libraries and plugins for integrating Ruby apps with Google App Engine. It is not required for deploying a ruby application to Google App Engine, but it provides a number of convenience hooks and tools for integrating into the App Engine environment.

Currently, it includes:

  • Automatic Stackdriver instrumentation for Rails apps. This means logs, error reports, and latency traces are reported to the cloud console, and debugger integration is available.
  • A client and rake tasks for executing application commands in the App Engine environment against production resources, useful for tasks such as running production database migrations.
  • Convenient access to environment information such as project ID and VM properties.

Potential future directions:

  • Tools for generating "app.yaml" configuration files for Ruby applications.
  • Streamlined implementation of health checks and other lifecycle hooks.

For more information on using Google Cloud Platform to deploy Ruby apps, please visit http://cloud.google.com/ruby

Installation

To install, include the "appengine" gem in your Gemfile. e.g.

gem "appengine"

Quick Start

Rails Quick Start

If you are running Ruby On Rails 4.0 or later, this gem will automatically install a Railtie that provides its capabilities. You may need to include the line:

require "appengine"

in your config/application.rb file if you aren't already requiring all bundled gems.

Rack Quick Start

If you are running a different Rack-based web framework, include the following line in your main Ruby file or config.ru:

require "appengine"

Then, to activate Stackdriver instrumentation, add the following middleware:

use Google::Cloud::Logging::Middleware
use Google::Cloud::ErrorReporting::Middleware
use Google::Cloud::Trace::Middleware
use Google::Cloud::Debugger::Middleware

You can add the Rake tasks to your application by adding the following to your Rakefile:

require "appengine/tasks"

Setting up appengine:exec remote execution

This gem is commonly used for its appengine:exec Rake task that provides a way to run production tasks such as database migrations in the cloud. If you are getting started with this feature, you should read the documentation (available on the AppEngine::Exec module) carefully, for important tips. In particular:

  • The strategy used by the gem is different depending on whether your app is deployed to the App Engine standard environment or flexible environment. It is important to understand which strategy is in use, because it affects which version of your application code is used to run the task, and various other factors.
  • You may need to grant additional permissions to the service account that runs the task. Again, the documentation will describe this in detail.
  • If your app is running on the flexible environment and uses a VPC (and connects to your database via a private IP address), then you will need to use a special configuration for the task.

Using this library

Logging and monitoring

This library automatically installs the "stackdriver" gem, which instruments your application to report logs, unhandled exceptions, and latency traces to your project's Google Cloud Console. For more information on the application monitoring features of Google App Engine, see:

Rails applications automatically activate this instrumentation when the gem is present. You may opt out of individual services by providing appropriate Rails configuration. See AppEngine::Railtie for more information.

Non-Rails applications must provide initialization code to activate this instrumentation, typically by installing a Rack middleware. You can find the basic code for installing these middlewares in the Rack Quick Start section above. See the individual service documentation links above for more information and configuration options.

App Engine remote execution

This library provides rake tasks for App Engine remote execution, allowing App Engine applications to perform on-demand tasks in the App Engine environment. This may be used for safe running of ops and maintenance tasks, such as database migrations, that access production cloud resources. For example, you could run a production database migration in a Rails app using:

bundle exec rake appengine:exec -- bundle exec rake db:migrate

The migration would be run in containers on Google Cloud infrastructure, which is much easier and safer than running the task on a local workstation and granting that workstation direct access to your production database.

See AppEngine::Exec for more information on App Engine remote execution.

See AppEngine::Tasks for more information on running the Rake tasks. The tasks are available automatically in Rails applications when the gem is present. Non-Rails applications may install the tasks by adding the line require "appengine/tasks" to the Rakefile.

Development and support

The source code for this gem is available on Github at https://github.com/GoogleCloudPlatform/appengine-ruby

Report bugs on Github issues at https://github.com/GoogleCloudPlatform/appengine-ruby/issues

Contributions are welcome. Please review the CONTRIBUTING.md file.

appengine-ruby's People

Contributors

dazuma avatar gokaykucuk avatar katsuyan avatar markbennett avatar release-please[bot] avatar tbpg avatar thagomizer avatar tpbowden avatar trambui09 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

appengine-ruby's Issues

appengine:exec region error

We recently upgraded from 0.6.0 to 0.7.0, and we're now encountering an error when running the following:

bundle exec rake appengine:exec GAE_PROJECT=my_project_name GAE_SERVICE=default GAE_TIMEOUT=60m -- echo foo

When we run the above, or any other command through appengine:exec, we get the following output:

** Invoke appengine:exec (first_time)
** Execute appengine:exec
Bad value for region: (value missing)

I'm assuming I need to configure something somewhere, but I've not been able to find anything about this message to indicate what's missing a region value and where I should be setting it. I thought initially that our appengine config was maybe missing something, but looking at the terraform file for the project, I see:

locals {
  google_region = "us-central1"
  google_zone = "us-central1-c"
  # ... more config after this...
}

And further on, this is referenced in places like:

module "app_engine_endpoint_groups" {
  source = "../../modules/app_engine_endpoint_groups"

  region = local.google_region
  service_names = ["default"]
}

So I'm not sure what else to be looking at.

Any help with how to resolve this error is appreciated.

NameError: uninitialized constant Gcloud

I am trying to shift my working Ruby on Rails app to Google App Engine from AWS and have been following guideline here.
I am stuck at Rails database migrations section where when I run bundle exec rake appengine:exec -- bundle exec rake db:migrate from my terminal I get the following error.

rake aborted!
NameError: uninitialized constant Gcloud
/home/md_farhan_memon/.rvm/gems/ruby-2.3.0/gems/appengine-0.4.2/lib/appengine/tasks.rb:228:in rescue in verify_gcloud_and_report_errors' /home/md_farhan_memon/.rvm/gems/ruby-2.3.0/gems/appengine-0.4.2/lib/appengine/tasks.rb:227:in verify_gcloud_and_report_errors'
/home/md_farhan_memon/.rvm/gems/ruby-2.3.0/gems/appengine-0.4.2/lib/appengine/tasks.rb:126:in block in setup_exec_task' /home/md_farhan_memon/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in eval'
/home/md_farhan_memon/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in <main>' AppEngine::Util::Gcloud::BinaryNotFound: GCloud binary not found in path /home/md_farhan_memon/.rvm/gems/ruby-2.3.0/gems/appengine-0.4.2/lib/appengine/util/gcloud.rb:97:in binary_path!'
/home/md_farhan_memon/.rvm/gems/ruby-2.3.0/gems/appengine-0.4.2/lib/appengine/util/gcloud.rb:143:in verify!' /home/md_farhan_memon/.rvm/gems/ruby-2.3.0/gems/appengine-0.4.2/lib/appengine/tasks.rb:227:in verify_gcloud_and_report_errors'
/home/md_farhan_memon/.rvm/gems/ruby-2.3.0/gems/appengine-0.4.2/lib/appengine/tasks.rb:126:in block in setup_exec_task' /home/md_farhan_memon/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in eval'
/home/md_farhan_memon/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `

'
Tasks: TOP => appengine:exec
(See full trace by running task with --trace)

Couldn't find any help on the internet, please suggest something.
Let me know if you need anything else.

GAE ruby standard environment w/nokogiri broken after some change from google

Reporting here because in the past this has been the only way to indirectly report an issue to the GAE ruby standard environment team in lieu of appropriate tags on stackoverflow.

It looks like the ruby GAE standard team changed something in their runtime 1-2 days ago that has broken any new deploys that use nokogiri (which is 90% of ruby apps).

Deploys that were previously working two days ago will now fail when rails tries to run with:

Bundler::GemNotFound: Could not find nokogiri-1.10.7 in any of the sources

It is impossible to re-produce this error locally for affected projects, and re-installing gems, updating gems, changing ruby versions, etc., seems to have no effect.

I think previously the runtime was including some pre-compiled nokogiri versions, and with this latest change they dropped some of the versions they were previously including, or something. Just a guess.

Would really appreciate it @dazuma if you guys pass this along to the ruby standard environment team.

English stackoverflow issue: here
Japanese stackoverflow issue posted by someone else: here

Can't run : bundle exec rake appengine:exec -- bundle exec rake db:migrate

Hi,

I deployed a rails app on Google App Engine successfully, and I created a new Cloud Sql Postgres instance.

I have an issue when I trying to run database migration using this command : "bundle exec rake appengine:exec -- bundle exec rake db:migrate".

Error returned : rake aborted! Don't know how to build task 'appengine:exec' (see --tasks)

When I check appengine gem directory I can't find tasks.rb and exec.rb files.

How can I resolve that ?

Support for Rails console

Looks like tasks and exec commands are meant to support only synchronous operations. Are there any plans to allow a long-running remote Rails console using the same mechanisms under the hood?

Can't run : bundle exec rake appengine:exec -- bundle exec rake db:migrate

Hey,

I'm having similar troubles to the problems raised in issue #6,

Following this tutorial, I deployed a rails app on Google App Engine successfully, and I created a new Cloud Sql Postgres instance. (I did this all online by using the google cloud shell and it's text editor)

When I run the "bundle exec rake appengine:exec -- bundle exec rake db:migrate" command needed to migrate the database I get:

---------- EXECUTE COMMAND ----------
bundle exec rake db:migrate
rake aborted!
PG::Error: invalid encoding name: postgresql
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:709:in `set_client_encoding'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:709:in `configure_connection'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:696:in `connect'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:220:in `initialize'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:38:in `new'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:38:in `postgresql_connection'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:759:in `new_connection'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:803:in `checkout_new_connection'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:782:in `try_to_checkout_new_connection'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:743:in `acquire_connection'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:500:in `checkout'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:374:in `connection'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:931:in `retrieve_connection'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_handling.rb:116:in `retrieve_connection'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_handling.rb:88:in `connection'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/schema_migration.rb:20:in `table_exists?'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/schema_migration.rb:24:in `create_table'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/migration.rb:1125:in `initialize'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/migration.rb:1007:in `new'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/migration.rb:1007:in `up'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/migration.rb:985:in `migrate'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/tasks/database_tasks.rb:171:in `migrate'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/railties/databases.rake:58:in `block (2 levels) in <top (required)>'
/app/vendor/bundle/ruby/2.3.0/gems/rake-12.2.1/exe/rake:27:in `<top (required)>'
/rbenv/versions/2.3.5/bin/bundle:22:in `load'
/rbenv/versions/2.3.5/bin/bundle:22:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
Debuggee gcp:566045598374:c7333d19324f1015 successfully registered
ERROR
ERROR: build step "gcr.io/google-appengine/exec-wrapper:latest" failed: exit status 1
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

ERROR: (gcloud.container.builds.submit) build 4499d498-9214-47cf-b13a-71b6c05044bf completed with status "FAILURE"
rake aborted!
AppEngine::Util::Gcloud::GcloudFailed: GCloud failed with result code 1
/home/solaocodes/.gems/gems/appengine-0.4.4/lib/appengine/util/gcloud.rb:175:in `execute'
/home/solaocodes/.gems/gems/appengine-0.4.4/lib/appengine/exec.rb:300:in `start'
/home/solaocodes/.gems/gems/appengine-0.4.4/lib/appengine/tasks.rb:252:in `start_and_report_errors'
/home/solaocodes/.gems/gems/appengine-0.4.4/lib/appengine/tasks.rb:152:in `block in setup_exec_task'
/home/solaocodes/.gems/gems/rake-12.2.1/exe/rake:27:in `<top (required)>'
/usr/local/bin/bundle:23:in `load'
/usr/local/bin/bundle:23:in `<main>'
Tasks: TOP => appengine:exec
(See full trace by running task with --trace)

Any thoughts on how I can fix this?

GCloud failed with result code 126 when running migrations

(appengine)[udi:soundprint/web]$ bundle exec rake appengine:exec -- bundle exec rake db:migrate
sh: /Users/udi/Downloads/google-cloud-sdk: is a directory
rake aborted!
AppEngine::Util::Gcloud::GcloudFailed: GCloud failed with result code 126
/Users/udi/.rbenv/versions/2.5.3/bin/bundle:23:in `load'
/Users/udi/.rbenv/versions/2.5.3/bin/bundle:23:in `<main>'
Tasks: TOP => appengine:exec
(See full trace by running task with --trace)

gcloud is in my path as far as I can tell. All other commands work, like gcloud config get-value project

(appengine)[udi:soundprint/web]$ which gcloud
/Users/udi/Downloads/google-cloud-sdk 2/bin/gcloud

What might I be doing wrong? Thanks!

Ruby 2.7.2 support

Is this works for ruby 2.7.2? Maybe you have a temporary solution to how i can fix this?
cannot load such file -- google/protobuf_c (LoadError)

Environment variables are not escaped in gcloud build config

If any environment variables used in the build config look like they can be substituted by gcloud build, it will cause the task to fail. For example, if you had an environment variable A=AB$C, rake appengine:exec[pwd] would fail with the following exception:

ERROR: (gcloud.builds.submit) INVALID_ARGUMENT: invalid build: key in the template "C" is not a valid built-in substitution

Cannot execute remote tasks when Identity Aware Proxy is on

Currently there is no way to execute remote tasks when the identity aware proxy is on. The task will simply fail when trying to poll the status over the newly deployed app engine version.

As a workaround, I've monkey patched the code in order to be able to supply a service account key file and a client id:

class AppEngine::Exec

  # PATCH - Memoize authorizer that will be used when polling the status
  def authorizer
    authorizer ||= begin
      key_path = ENV['GAE_SERVICE_ACCOUNT_KEY_PATH']
      client_id = ENV['GAE_IAM_CLIENT_ID']

      if client && key_path
        puts "Using IAM authorizer with GAE_SERVICE_ACCOUNT_KEY_PATH: #{key_path} and GAE_IAM_CLIENT_ID: #{client_id}"
        Google::Auth::ServiceAccountCredentials.make_creds(
          json_key_io: File.open(key_path),
          target_audience: client_id
        )
      end
    end
  end

  def track_status temp_version, secret
    host = "#{temp_version}.#{@service}.#{@project}.appspot.com"
    ::Net::HTTP.start host do |http|
      outpos = errpos = 0
      delay = 0.0
      loop do
        sleep delay
        uri = URI("http://#{host}/#{secret}")
        uri.query = ::URI.encode_www_form outpos: outpos, errpos: errpos

        # BEGIN PATCH - Adding authorizer while polling the status
        req = Net::HTTP::Get.new(uri)
        authorizer&.apply!(req)
        response = http.request(req)
        # END PATCH - Adding authorizer while polling the status

        data = ::JSON.parse response.body
        data["outlines"].each { |line| puts "[STDOUT] #{line}" }
        data["errlines"].each { |line| puts "[STDERR] #{line}" }
        outpos = data["outpos"]
        errpos = data["errpos"]
        return data["status"] if data["status"]
        if data["time"] > @timeout_seconds

          # BEGIN PATCH - Adding authorizer while polling the status
          req = Net::HTTP::Post.new("/#{secret}/kill")
          authorizer&.apply!(req)
          http.request(req)
          # END PATCH - Adding authorizer while polling the status

          return "timeout"
        end
        if data["outlines"].empty? && data["errlines"].empty?
          delay += 0.1
          delay = 1.0 if delay > 1.0
        else
          delay = 0.0
        end
      end
    end
  end
end

cloud build exec Permission denied

Change the execution user in the docker container from root to a regular user and run cloud build

Dockerfile
USER app

bundle exec rake appengine:exec -- bundle exec rake db:migrate.
If you run
Permission denied.

cloudbuild.yaml

- name: gcr.io/$PROJECT_ID/${_GAE_SERVICE}:${_COMMIT_SHA}
  entrypoint: '/bin/bash'
  args:
  - '-c'
  - |
    bundle exec rake appengine:exec  -- bundle exec rails db:migrate
  id: migrate
Step #1 - "migrate": `/builder/home` is not writable.
Step #1 - "migrate": Bundler will use `/app/tmp/bundler20210208-1-x6dat21' as your home directory temporarily.
Step #1 - "migrate": rake aborted!
Step #1 - "migrate": Errno::EACCES: Permission denied @ dir_s_mkdir - /workspace/tmp/cache

When I run it manually, I can run it without any problem.

Is there any workaround for this?

Google Cloud Sql Mysql2:Error Access denied

How does this command "bundle exec rake appengine:exec -- bundle exec rake db:migrate" works?

Everytime the i run the command,connecting cloudsql is working, but when execute command, i always end up with "Mysql2::Error: Access denied for user 'root'@'[Different_IP_Address_That_Keep_Changing]' (using password: YES)."

At first, i thought, wrong password or not authorized by Google Cloud Sql, but i already set 'root'@'%' and 0.0.0.0/0 in my google cloud sql instance.. I already tried grant all privileges manually in my local db and sql instance db. But i have no problem connecting with "gcloud sql connect". I tried to include sslca,sslcert, and sslkey in my database.yml even though i didnt activate ssl only options in sql cloud. I also tried grant permission for appengine gem and giving role editor to my [PROJECT_NUMBER]@cloudbuild.gserviceaccount.com.

Then i tried to change my bash_profile environment and app.yml , but it seems that appengine is ignoring these configuration, even though i comment out every env variables in app.yml & bash_profile, then beta_settings in app.yml, i still can do this "bundle exec rake appengine:exec -- bundle exec rake db:migrate" and get this error "Mysql2::Error: Access denied for user 'root'@'[Different_IP_Address_That_Keep_Changing]' (using password: YES)."

Can anyone help me what step did i do wrong :(

Invalid logs bucket when running db:migrate

I've followed steps outlined in the README and also assigned Editor role to the cloudbuilder service account, but am now running into the following error when running the db:migrate command.

ERROR: (gcloud.container.builds.submit) INVALID_ARGUMENT: invalid logs bucket gs://{project_name}_cloudbuild/logs

I've omitted the actual project name, but I wasn't sure if this is behavior that others have run into. Creating this bucket manually and ensuring that the cloudbuilder role can deploy builds into it fixed this particular error.

Missing container image from gcloud app versions describe VERSION

Hello,

I'm new to gcloud and trying to set up a rails app based on the docs. I'm not sure if this is a appengine-ruby probably not since the gcloud CLI is giving the same results. Not sure where I messed up but when I run

bundle exec rake appengine:exec -- bundle exec rake db:migrate

I get the following error

rake aborted!
NoMethodError: undefined method `[]' for nil:NilClass
/Users/laerti.papa/.rvm/gems/ruby-2.6.3/gems/appengine-0.5.0/lib/appengine/exec.rb:754:in `start_build_strategy'
/Users/laerti.papa/.rvm/gems/ruby-2.6.3/gems/appengine-0.5.0/lib/appengine/exec.rb:491:in `start'
/Users/laerti.papa/.rvm/gems/ruby-2.6.3/gems/appengine-0.5.0/lib/appengine/tasks.rb:317:in `start_and_report_errors'
/Users/laerti.pap

I debugged a bit and I saw that apparently the app_info hash is missing the ["deployment"]["container"]["image"]: https://github.com/GoogleCloudPlatform/appengine-ruby/blob/master/lib/appengine/exec.rb#L754

Running the deployment strategy I have other issues but for now I try to understand why cloud_build does not work or why the image is not there when I run describe app version.

Any help would be much appreciated. Thank you.

appengine:exec can't connect to Cloud SQL DB with private IP

I have Rails application and Cloud SQL (PostgreSQL) database with Private IP.
When I'm trying to run any task with appengine:exec I get PG::ConnectionBad error.
I've created another database, but this time with public IP, and everything worked fine.

Here is the error:

rake aborted!
PG::ConnectionBad: server closed the connection unexpectedly
	This probably means the server terminated abnormally
	before or while processing the request.
/app/vendor/bundle/ruby/2.6.0/gems/pg-1.1.4/lib/pg.rb:56:in `initialize'
/app/vendor/bundle/ruby/2.6.0/gems/pg-1.1.4/lib/pg.rb:56:in `new'
/app/vendor/bundle/ruby/2.6.0/gems/pg-1.1.4/lib/pg.rb:56:in `connect'
/app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/postgresql_adapter.rb:692:in `connect'
/app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/postgresql_adapter.rb:223:in `initialize'
/app/vendor/bundle/ruby/2.6.0/gems/activerecord-postgis-adapter-5.2.2/lib/active_record/connection_adapters/postgis_adapter.rb:62:in `initialize'
/app/vendor/bundle/ruby/2.6.0/gems/activerecord-postgis-adapter-5.2.2/lib/active_record/connection_adapters/postgis/create_connection.rb:40:in `new'
/app/vendor/bundle/ruby/2.6.0/gems/activerecord-postgis-adapter-5.2.2/lib/active_record/connection_adapters/postgis/create_connection.rb:40:in `postgis_connection'
/app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:811:in `new_connection'
/app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:855:in `checkout_new_connection'
/app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:834:in `try_to_checkout_new_connection'
/app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:795:in `acquire_connection'
/app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:523:in `checkout'
/app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:382:in `connection'
/app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:1010:in `retrieve_connection'
/app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.2/lib/active_record/connection_handling.rb:118:in `retrieve_connection'
/app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.2/lib/active_record/connection_handling.rb:90:in `connection'
/app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.2/lib/active_record/model_schema.rb:324:in `table_exists?'
/app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.2/lib/active_record/attribute_methods/primary_key.rb:99:in `get_primary_key'
/app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.2/lib/active_record/attribute_methods/primary_key.rb:87:in `reset_primary_key'
/app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.2/lib/active_record/attribute_methods/primary_key.rb:75:in `primary_key'
/app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.2/lib/active_record/relation/delegation.rb:76:in `primary_key'
/app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.2/lib/active_record/relation/batches.rb:274:in `batch_order'
/app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.2/lib/active_record/relation/batches.rb:217:in `in_batches'
/app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.2/lib/active_record/relation/batches.rb:135:in `find_in_batches'
/app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.2/lib/active_record/relation/batches.rb:69:in `find_each'
/app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.2/lib/active_record/querying.rb:11:in `find_each'
/app/config/sitemap.rb:24:in `block (2 levels) in run'
/app/vendor/bundle/ruby/2.6.0/gems/sitemap_generator-6.0.2/lib/sitemap_generator/interpreter.rb:61:in `instance_eval'
/app/vendor/bundle/ruby/2.6.0/gems/sitemap_generator-6.0.2/lib/sitemap_generator/interpreter.rb:61:in `eval'
/app/vendor/bundle/ruby/2.6.0/gems/sitemap_generator-6.0.2/lib/sitemap_generator/link_set.rb:240:in `group'
/app/vendor/bundle/ruby/2.6.0/gems/sitemap_generator-6.0.2/lib/sitemap_generator/interpreter.rb:45:in `group'
/app/config/sitemap.rb:21:in `block in run'
/app/vendor/bundle/ruby/2.6.0/gems/sitemap_generator-6.0.2/lib/sitemap_generator/interpreter.rb:61:in `instance_eval'
/app/vendor/bundle/ruby/2.6.0/gems/sitemap_generator-6.0.2/lib/sitemap_generator/interpreter.rb:61:in `eval'
/app/vendor/bundle/ruby/2.6.0/gems/sitemap_generator-6.0.2/lib/sitemap_generator/link_set.rb:40:in `create'
/app/vendor/bundle/ruby/2.6.0/gems/sitemap_generator-6.0.2/lib/sitemap_generator.rb:41:in `method_missing'
/app/config/sitemap.rb:17:in `run'
/app/vendor/bundle/ruby/2.6.0/gems/sitemap_generator-6.0.2/lib/sitemap_generator/interpreter.rb:78:in `instance_eval'
/app/vendor/bundle/ruby/2.6.0/gems/sitemap_generator-6.0.2/lib/sitemap_generator/interpreter.rb:78:in `run'
/app/vendor/bundle/ruby/2.6.0/gems/sitemap_generator-6.0.2/lib/sitemap_generator/tasks.rb:51:in `block (2 levels) in <main>'
/app/vendor/bundle/ruby/2.6.0/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
/opt/rbenv/versions/2.6.1/bin/bundle:23:in `load'
/opt/rbenv/versions/2.6.1/bin/bundle:23:in `<main>'
Tasks: TOP => sitemap:refresh => sitemap:create
(See full trace by running task with --trace)
ERROR
ERROR: build step 0 "gcr.io/google-appengine/exec-wrapper:latest" failed: exit status 1

Is there any way to get around this issue? Can't find anything related in docs and source code.

Is this actively maintained?

Hello appengine-ruby team,
I'm trying to evaluate whether I will implement this gem in my project and see the last commit was 17 months ago.
Could someone from the maintainers team give me an idea if this is actively maintained? It seems not to be.
Thank you!
Best,
Laura

Error deploy Rails

Hi, I'm with problem for deploy rails in appengine.

It is presenting current error:

Step #1: success Saved lockfile.
Step #1: Done in 0.07s.
Step #1: /app/vendor/bundle/ruby/2.4.0/gems/google-cloud-logging-1.6.0/lib/google/cloud/logging/async_writer.rb:423:in `publish_batch_async': uninitialized constant Concurrent::Promises (NameError)
Step #1: 	from /app/vendor/bundle/ruby/2.4.0/gems/google-cloud-logging-1.6.0/lib/google/cloud/logging/async_writer.rb:396:in `publish_batch!'
Step #1: 	from /app/vendor/bundle/ruby/2.4.0/gems/google-cloud-logging-1.6.0/lib/google/cloud/logging/async_writer.rb:212:in `block in stop'
Step #1: 	from /opt/rbenv/versions/2.4.2/lib/ruby/2.4.0/monitor.rb:214:in `mon_synchronize'
Step #1: 	from /app/vendor/bundle/ruby/2.4.0/gems/google-cloud-logging-1.6.0/lib/google/cloud/logging/async_writer.rb:208:in `stop'
Step #1: 	from /app/vendor/bundle/ruby/2.4.0/gems/google-cloud-logging-1.6.0/lib/google/cloud/logging/async_writer.rb:86:in `block in initialize'
Step #1: Removing intermediate container b05e3c93fc9f
Step #1:  ---> 53f45fb74bb9

Error connecting to Redis (Redis::TimeoutError) (Redis::CannotConnectError)

I have a rack app with redis, the app is working fine but when I try to run a script using appengine:exec I receive a timeout error.

Any help would be appreciate it.

 bundle exec rake appengine:exec GAE_PROJECT=machinal-test GAE_CONFIG=app-development.yaml -- bundle exec ruby scripts/update_leaderboards.rb

Using the `cloud_build` strategy for appengine:exec
(i.e. running your app image in Cloud Build)
PROJECT: machinal-test
SERVICE: default
VERSION: 20200811t172903
TIMEOUT: 30m

Created [https://cloudbuild.googleapis.com/v1/projects/machinal-test/builds/1d90cf68-0cd3-471c-8095-e4784e13f709].
Logs are available at [https://console.cloud.google.com/cloud-build/builds/1d90cf68-0cd3-471c-8095-e4784e13f709?project=517948324116].
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------- REMOTE BUILD OUTPUT ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
starting build "1d90cf68-0cd3-471c-8095-e4784e13f709"

FETCHSOURCE
BUILD
Pulling image: gcr.io/google-appengine/exec-wrapper:latest
latest: Pulling from google-appengine/exec-wrapper
75f546e73d8b: Already exists
0f3bb76fc390: Already exists
3c2cba919283: Already exists
60a2832f551e: Pulling fs layer
261fe7768d03: Pulling fs layer
1a1bdff19664: Pulling fs layer
1a1bdff19664: Verifying Checksum
1a1bdff19664: Download complete
261fe7768d03: Verifying Checksum
261fe7768d03: Download complete
60a2832f551e: Verifying Checksum
60a2832f551e: Download complete
60a2832f551e: Pull complete
261fe7768d03: Pull complete
1a1bdff19664: Pull complete
Digest: sha256:6819234d5d981983dc4d7afd3722d35194d3e10264218515a0577fcf93f06993
Status: Downloaded newer image for gcr.io/google-appengine/exec-wrapper:latest
gcr.io/google-appengine/exec-wrapper:latest

---------- INSTALL IMAGE ----------
sha256:71b97a04a5bde5aecf5132261df1231e113348d852880a79eb9bc2202f7f8211: Pulling from machinal-test/appengine/default.20200811t172903
bd47987755ba: Pulling fs layer
831c222b21d8: Pulling fs layer
3c2cba919283: Pulling fs layer
d4078914ea9b: Pulling fs layer
0b738ba60421: Pulling fs layer
b36ab2b2370c: Pulling fs layer
2a1964acb7aa: Pulling fs layer
5548dfc15af8: Pulling fs layer
2b63f569a95a: Pulling fs layer
9c2ba3f56571: Pulling fs layer
d4078914ea9b: Waiting
0b738ba60421: Waiting
b36ab2b2370c: Waiting
2a1964acb7aa: Waiting
5548dfc15af8: Waiting
9c2ba3f56571: Waiting
2b63f569a95a: Waiting
3c2cba919283: Verifying Checksum
3c2cba919283: Download complete
831c222b21d8: Verifying Checksum
831c222b21d8: Download complete
0b738ba60421: Verifying Checksum
0b738ba60421: Download complete
b36ab2b2370c: Verifying Checksum
b36ab2b2370c: Download complete
bd47987755ba: Verifying Checksum
bd47987755ba: Download complete
2a1964acb7aa: Verifying Checksum
2a1964acb7aa: Download complete
2b63f569a95a: Verifying Checksum
2b63f569a95a: Download complete
5548dfc15af8: Verifying Checksum
5548dfc15af8: Download complete
9c2ba3f56571: Verifying Checksum
9c2ba3f56571: Download complete
d4078914ea9b: Verifying Checksum
d4078914ea9b: Download complete
bd47987755ba: Pull complete
831c222b21d8: Pull complete
3c2cba919283: Pull complete
d4078914ea9b: Pull complete
0b738ba60421: Pull complete
b36ab2b2370c: Pull complete
2a1964acb7aa: Pull complete
5548dfc15af8: Pull complete
2b63f569a95a: Pull complete
9c2ba3f56571: Pull complete
Digest: sha256:71b97a04a5bde5aecf5132261df1231e113348d852880a79eb9bc2202f7f8211
Status: Downloaded newer image for us.gcr.io/machinal-test/appengine/default.20200811t172903@sha256:71b97a04a5bde5aecf5132261df1231e113348d852880a79eb9bc2202f7f8211

---------- CONNECT CLOUDSQL ----------
cloud_sql_proxy is running.

---------- EXECUTE COMMAND ----------
bundle exec ruby scripts/update_leaderboards.rb
Database settings: {:adapter=>"postgres", :host=>"/cloudsql/machinal-test:us-central1:machinal-development", :database=>"machinal_data_server", :user=>"machinal_api"}
Redis settings: {:host=>"10.7.90.107", :port=>"6379"}
/app/vendor/bundle/ruby/2.5.0/gems/redis-4.2.1/lib/redis/client.rb:362:in `rescue in establish_connection': Error connecting to Redis on 10.7.90.107:6379 (Redis::TimeoutError) (Redis::CannotConnectError)
	from /app/vendor/bundle/ruby/2.5.0/gems/redis-4.2.1/lib/redis/client.rb:343:in `establish_connection'
	from /app/vendor/bundle/ruby/2.5.0/gems/redis-4.2.1/lib/redis/client.rb:107:in `block in connect'
	from /app/vendor/bundle/ruby/2.5.0/gems/redis-4.2.1/lib/redis/client.rb:308:in `with_reconnect'
	from /app/vendor/bundle/ruby/2.5.0/gems/redis-4.2.1/lib/redis/client.rb:106:in `connect'
	from /app/vendor/bundle/ruby/2.5.0/gems/redis-4.2.1/lib/redis/client.rb:381:in `ensure_connected'
	from /app/vendor/bundle/ruby/2.5.0/gems/redis-4.2.1/lib/redis/client.rb:233:in `block in process'
	from /app/vendor/bundle/ruby/2.5.0/gems/redis-4.2.1/lib/redis/client.rb:320:in `logging'
	from /app/vendor/bundle/ruby/2.5.0/gems/redis-4.2.1/lib/redis/client.rb:232:in `process'
	from /app/vendor/bundle/ruby/2.5.0/gems/redis-4.2.1/lib/redis/client.rb:198:in `call_pipelined'
	from /app/vendor/bundle/ruby/2.5.0/gems/redis-4.2.1/lib/redis/client.rb:165:in `block in call_pipeline'
	from /app/vendor/bundle/ruby/2.5.0/gems/redis-4.2.1/lib/redis/client.rb:308:in `with_reconnect'
	from /app/vendor/bundle/ruby/2.5.0/gems/redis-4.2.1/lib/redis/client.rb:163:in `call_pipeline'
	from /app/vendor/bundle/ruby/2.5.0/gems/redis-4.2.1/lib/redis.rb:2492:in `block in multi'
	from /app/vendor/bundle/ruby/2.5.0/gems/redis-4.2.1/lib/redis.rb:69:in `block in synchronize'
	from /opt/rbenv/versions/2.5.7/lib/ruby/2.5.0/monitor.rb:235:in `mon_synchronize'
	from /app/vendor/bundle/ruby/2.5.0/gems/redis-4.2.1/lib/redis.rb:69:in `synchronize'
	from /app/vendor/bundle/ruby/2.5.0/gems/redis-4.2.1/lib/redis.rb:2484:in `multi'
	from /app/vendor/bundle/ruby/2.5.0/gems/leaderboard-3.12.1/lib/leaderboard.rb:142:in `rank_member_in'
	from /app/vendor/bundle/ruby/2.5.0/gems/leaderboard-3.12.1/lib/leaderboard.rb:132:in `rank_member'
	from scripts/update_leaderboards.rb:8:in `block (2 levels) in <main>'
	from /app/vendor/bundle/ruby/2.5.0/gems/sequel-5.32.0/lib/sequel/dataset/actions.rb:150:in `block in each'
	from /app/vendor/bundle/ruby/2.5.0/gems/sequel-5.32.0/lib/sequel/adapters/postgres.rb:614:in `block (2 levels) in fetch_rows'
	from /app/vendor/bundle/ruby/2.5.0/gems/sequel-5.32.0/lib/sequel/adapters/postgres.rb:800:in `yield_hash_rows'
	from /app/vendor/bundle/ruby/2.5.0/gems/sequel-5.32.0/lib/sequel/adapters/postgres.rb:614:in `block in fetch_rows'
	from /app/vendor/bundle/ruby/2.5.0/gems/sequel-5.32.0/lib/sequel/adapters/postgres.rb:146:in `execute'
	from /app/vendor/bundle/ruby/2.5.0/gems/sequel-5.32.0/lib/sequel/adapters/postgres.rb:500:in `_execute'
	from /app/vendor/bundle/ruby/2.5.0/gems/sequel-5.32.0/lib/sequel/adapters/postgres.rb:318:in `block (2 levels) in execute'
	from /app/vendor/bundle/ruby/2.5.0/gems/sequel-5.32.0/lib/sequel/adapters/postgres.rb:522:in `check_database_errors'
	from /app/vendor/bundle/ruby/2.5.0/gems/sequel-5.32.0/lib/sequel/adapters/postgres.rb:318:in `block in execute'
	from /app/vendor/bundle/ruby/2.5.0/gems/sequel-5.32.0/lib/sequel/connection_pool/threaded.rb:92:in `hold'
	from /app/vendor/bundle/ruby/2.5.0/gems/sequel-5.32.0/lib/sequel/database/connecting.rb:270:in `synchronize'
	from /app/vendor/bundle/ruby/2.5.0/gems/sequel-5.32.0/lib/sequel/adapters/postgres.rb:318:in `execute'
	from /app/vendor/bundle/ruby/2.5.0/gems/sequel-5.32.0/lib/sequel/dataset/actions.rb:1089:in `execute'
	from /app/vendor/bundle/ruby/2.5.0/gems/sequel-5.32.0/lib/sequel/adapters/postgres.rb:614:in `fetch_rows'
	from /app/vendor/bundle/ruby/2.5.0/gems/sequel-5.32.0/lib/sequel/dataset/actions.rb:150:in `each'
	from /app/vendor/bundle/ruby/2.5.0/gems/sequel-5.32.0/lib/sequel/model/plugins.rb:33:in `each'
	from scripts/update_leaderboards.rb:7:in `block in <main>'
	from scripts/update_leaderboards.rb:5:in `each'
	from scripts/update_leaderboards.rb:5:in `<main>'
ERROR
ERROR: build step 0 "gcr.io/google-appengine/exec-wrapper:latest" failed: step exited with non-zero status: 1
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

ERROR: (gcloud.builds.submit) build 1d90cf68-0cd3-471c-8095-e4784e13f709 completed with status "FAILURE"
rake aborted!
AppEngine::Util::Gcloud::GcloudFailed: GCloud failed with result code 1
/Users/jonas/.rbenv/versions/2.5.7/bin/bundle:23:in `load'
/Users/jonas/.rbenv/versions/2.5.7/bin/bundle:23:in `<main>'
Tasks: TOP => appengine:exec
(See full trace by running task with --trace)

Migration when postgres DB is hosted on Compute Engine VM

Hi,
Really enjoying running rails on AppEngine, however, due to some compliance requirements around customer supplied keys, we've had to run our database on a Compute Engine VM.

This all works perfectly except for running the migrations through the app engine command line tool, I get the following error:

New Error: PG::ConnectionBad: could not connect to server: Connection timed out, Is the server running on host "10.152.x.x" and accepting TCP/IP connections on port 5432

Due to this, I have to manually SSH into the App engine containers and run it from within the context of the app file. How can I execute the migration so it can access the PG VM running on Compute Engine?

Cheers

Can't start cloud_sql_proxy

I've been trying to use this project run database migrations on an app running in the Google App Engine Ruby environment.

When I run bundle exec rake appengine:exec -- bundle exec rake db:migrate, it downloads some images and then runs into this error:

---------- CONNECT CLOUDSQL ----------
ERROR: Failed to start cloud_sql_proxy
2017/08/23 18:09:11 errors parsing config:
	googleapi: Error 403: The client is not authorized to make this request., notAuthorized
ERROR
ERROR: build step "gcr.io/google-appengine/exec-wrapper" failed: exit status 1

I'm not sure how I can debug this is it is a permission issue on my end. I also tried building the cloudbuild.json file manually to test different cases. If I remove the arg -s which seems to corrispond to Cloud SQL, then it procceds, but it then fails as it can't connect the DB.

If there are other things I can try to debug I'm all ears.

Specify project via environment variable

I deploy into multiple GCloud projects, and would like to be able to specify the project id via an environment variable when calling rake appengine:exec, similar to how ie. GAE_SERVICE can be specified.

As far as I can see from the source code, this is not currently possible?

JSON Parse Error appears randomly on some runs

Problem

Executing bundle exec rake appengine:exec GAE_CONFIG=xxxx GAE_TIMEOUT=xx -- bundle exec bin/rails db:migrate on Gitlab CI/CD, some times throws an error related with JSON parser. After rerunning the job, it works perfectly (without any change on code nor files). There is no pattern apparently.

The target system is deployed on App Engine Standard, we've migrated from App Engine Flexible where it used to work perfectly, so it could be related to some App Engine Standard specific configuration.

Trace

---------- EXECUTE COMMAND ----------
COMMAND: ["bundle", "exec", "bin/rails", "db:migrate"]
---------- CLEANUP ----------
Deleting the following versions:
 - XXXXXXXXXXXXXXXXXXXXXXXXXX
Deleting [default/appengine-exec-XXXXXXXXXX]...
.....done.
rake aborted!
JSON::ParserError: 783: unexpected token at ''
/usr/local/bin/bundle:23:in `load'
/usr/local/bin/bundle:23:in `<main>'
Tasks: TOP => appengine:exec
(See full trace by running task with --trace)
Cleaning up file based variables
ERROR: Job failed: command terminated with exit code 1

Versions

appengine-ruby: 0.6.0
ruby: 2.6.2
rails version: 6.0.2.2
App Engine Standard

Ruby 2.5 Support

When trying to install with Ruby 2.5:

Fetching gem metadata from https://rubygems.org/...........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies....
google-protobuf-3.5.1-universal-darwin requires ruby version < 2.5, which is incompatible with the current version, ruby 2.5.0p0

docker: invalid reference format during db:migrate

After building the image, I see the following when running bundle exec rake appengine:exec -- bundle exec rake db:migrate

---------- CONNECT CLOUDSQL ----------
cloud_sql_proxy is running.

---------- EXECUTE COMMAND ----------
bundle exec rake db:migrate
docker: invalid reference format.
See 'docker run --help'.
ERROR
ERROR: build step "gcr.io/google-appengine/exec-wrapper" failed: exit status 125

Nothing seems to be generated in the logs, though it seems to be a Docker issue?

Dependencies not installed by bundler

My Gemfile has this

group :production do
  gem 'appengine'
end

I run bundle install and everything is installed. Then I run rake and I get this error:

Could not find google-cloud-debugger-0.32.0 in any of the sources

Rake exits telling me to run bundle install for missing gems.

This is on my development machine. I tried eliminating the "group production" and just having it flat in the Gemfile and it didn't fix the issue.

Ruby version: ruby 2.3.3p222
Rails version: 5.2
Bundler version: 1.16.2

Run rails server when call db:migrate

How can I call migrate?

$ bundle exec rake appengine:exec GAE_CONFIG=gcp/app_prd.yaml -- bundle exec rake db:migrate

Using the `cloud_build` strategy for appengine:exec
(i.e. running your app image in Cloud Build)
PROJECT: xxx
SERVICE: default
VERSION: 20200602t090012
TIMEOUT: 10m

...

---------- CONNECT CLOUDSQL ----------
cloud_sql_proxy is running.

---------- EXECUTE COMMAND ----------
bundle exec rake db:migrate
2
=> Booting Puma
=> Rails 5.2.2.1 application starting in staging
=> Run `rails server -h` for more startup options
2
Creating scope :board_plan_count. Overwriting existing method Forecast.board_plan_count.
Creating scope :column. Overwriting existing method Story.column.
Creating scope :comment. Overwriting existing method Notification.comment.
Creating scope :open. Overwriting existing method Recruit.open.
Puma starting in single mode...
* Version 4.3.5 (ruby 2.6.2-p47), codename: Mysterious Traveller
* Min threads: 5, max threads: 5
* Environment: staging
* Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop

How to set the value of timeout?

Could not find this documented anywhere other than when creating a build configuration file, which I am not interested in.

I'm trying to run the following command:
bundle exec rake appengine:exec -- bundle exec rake db:seed

Although it only takes under two minutes when I seed my local database, it is apparently taking much longer on the server. Any help would be appreciated.

env_variables cannot be used in deployment

Hi,

This is a issue about ruby25_app_builder rather than this gem.
Sorry if it isn't the right place to ask.

I found that environment variables defined in app.yaml cannot be used in gcloud app deploy.

For example, my Rails app initializes an API client on launch.
So I wrote an initializer that reads API key from environment variable:

config/initializers/sample_initializer.rb

api_key = ENV['SAMPLE_API_KEY']
raise 'sample_api_key is required' if api_key.blank?

SampleClient.config.api_key = api_key

Then I deploy this app with gcloud app deploy.
During deploy, ruby25_app_builder automatically runs rails assets:precompile if public/assets does not exists.
But this command fails due to missing env var.

Logs from Cloud Build:

Step #1 - "builder": [2019-12-15 09:59:24 INFO] => Checking for Rails sprockets
Step #1 - "builder": [2019-12-15 09:59:24 INFO] => Running Rails asset precompilation
Step #1 - "builder": [2019-12-15 09:59:24 INFO] ["bundle", "exec", "bin/rails", "assets:precompile"]
Step #1 - "builder": rails aborted!
Step #1 - "builder": sample_api_key is required

This can be avoided by running RAILS_ENV=production rails assets:precompile in advance.
But I think this should be done by ruby25_app_builder.
Are there any plans to fix this?

Apple M1 support

This gem doesn't work on macs with M1

dlopen(/Users/lincalinc/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/google-protobuf-3.14.0-universal-darwin/lib/google/2.7/protobuf_c.bundle, 9): no suitable image found.  Did find: (LoadError)
	/Users/lincalinc/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/google-protobuf-3.14.0-universal-darwin/lib/google/2.7/protobuf_c.bundle: mach-o, but wrong architecture
	/Users/lincalinc/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/google-protobuf-3.14.0-universal-darwin/lib/google/2.7/protobuf_c.bundle: mach-o, but wrong architecture - /Users/lincalinc/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/google-protobuf-3.14.0-universal-darwin/lib/google/2.7/protobuf_c.bundle

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.