简体   繁体   中英

Deploy Ruby on Rails app to App Engine using Cloud Build

I'm trying to automate the deployment of a Ruby on Rails app to App Engine using Cloud Build.

My app.yaml looked like this,

runtime: ruby
env: flex
entrypoint: bundle exec rails server

But I'm getting this error,

Step #1: ERROR: (gcloud.app.deploy) There is a cloudbuild.yaml in the current directory, and the runtime field in /workspace/app.yaml is currently set to [runtime: ruby]. To use your cloudbuild.yaml to build a custom runtime, set the runtime field to [runtime: custom]. To continue using the [ruby] runtime, please remove the cloudbuild.yaml from this directory.

Then I tried to change the runtime to custom and add a Dockerfile as custom runtime needs a Dockerfile.

But now I'm getting an error saying,

ERROR: (gcloud.app.deploy) A custom runtime must have exactly one of [Dockerfile] and [cloudbuild.yaml] in the source directory; [/home/milindu/Projects/ElePath-Ruby] contains both

Then I removed Dockerfile also. But now getting into this weird situation. You can see the 'Step #1:' is growing into several like stuck in a recursion.

错误控制台

Cloudbuild.yaml should work with App Engine Flexible without the need to use a custom runtime. As detailed in the first error message you received, you cannot have an app.yaml and the cloudbuild.yaml in the same directory if you are deploying in a non-custom runtime, to remedy the situation, follow these steps:

  1. Move your app.yaml and other ruby files into a subdirectory (use your original app.yaml, no need to use custom runtime)

  2. Under your cloudbuild.yaml steps, modify the argument for app deploy by adding a third one specifying your app.yaml's path.

Below is an example:

==================FROM:

steps: 
- name: 'gcr.io/cloud-builders/gcloud' 
args: ['app', 'deploy'] 
timeout: '1600s' 
===================TO:

steps: 
- name: 'gcr.io/cloud-builders/gcloud' 
args: ['app', 'deploy', '[SUBDIRECTORY/app.yaml]'] 
timeout: '1600s' 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM