0

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.

Error console

Milindu Sanoj Kumarage
  • 2,714
  • 2
  • 31
  • 54

1 Answers1

2

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' 
David
  • 646
  • 4
  • 14
  • Thanks @David, I tried this and it worked. Now the problem is, this is an open source project and I can't move all the codes into a subdirectory just for Cloud Build. Is there a workaround you can think of? Is there a way to keep just `app.yaml` in a subdir and do it or any other trick? – Milindu Sanoj Kumarage Nov 24 '18 at 06:41
  • I do not have a workaround for you at this time. However, this might be possible by using custom run times and a Docker file but I understand this might not be ideal. If you believe this is something critical for you, you can create a feature request on [Issue Tracker](https://cloud.google.com/support/docs/issue-trackers) by giving some context and providing your use case. – David Nov 28 '18 at 19:31