错误:(gcloud.preview.app.deploy)错误响应:[2]构建失败;

时间:2016-04-27 00:00:47

标签: ruby-on-rails ruby google-app-engine

我正在运行谷歌应用引擎 - ruby​​ on rails示例一切顺利,我必须部署应用程序。

google app engine ruby on rails tutorial

这是控制台输出,导致错误

Beginning deployment...
If this is your first deployment, this may take a while...done.

Verifying that Managed VMs are enabled and ready.
Building and pushing image for service [default]
Started cloud build [c80b8677-2cff-4341-a6f7-b97a55b5fb83].
To see logs in the Cloud Console: https://console.developers.google.com/logs?project=cloud-compute-rails&service=cloudbuild.googleapis.com&key1=c80b8677-2cff-4341-a6f7-b97a55b5fb83&logName=projects/cloud-compute-rails/logs/cloudbuild
----------------------------- REMOTE BUILD OUTPUT ------------------------------
starting build "c80b8677-2cff-4341-a6f7-b97a55b5fb83"

FETCHSOURCE
Fetching storage object: gs://staging.cloud-compute-rails.appspot.com/us.gcr.io/cloud-compute-rails/appengine/default.20160427t004918:latest#1461714651629000
Copying gs://staging.cloud-compute-rails.appspot.com/us.gcr.io/cloud-compute-rails/appengine/default.20160427t004918:latest#1461714651629000...
Downloading file:///tmp/source-archive.tgz:                      0 B/203.33 KiB Downloading file:///tmp/source-archive.tgz:                      72 KiB/203.33 KDownloading file:///tmp/source-archive.tgz:                      144 KiB/203.33 Downloading file:///tmp/source-archive.tgz:                      203.33 KiB/203.33 KiB
FETCHBUILDER
BUILD
+ docker version
Client:
 Version:      1.9.1
 API version:  1.21
 Go version:   go1.4.3
 Git commit:   a34a1d5
 Built:        Fri Nov 20 17:56:04 UTC 2015
 OS/Arch:      linux/amd64

Server:
 Version:      1.9.1
 API version:  1.21
 Go version:   go1.4.2
 Git commit:   a34a1d5
 Built:        Fri Nov 20 13:12:04 UTC 2015
 OS/Arch:      linux/amd64
+ cat Dockerfile
# This Dockerfile for a Ruby application was generated by gcloud.

# The base Dockerfile installs:
# * A number of packages needed by the Ruby runtime and by gems
#   commonly used in Ruby web apps (such as libsqlite3)
# * A recent version of NodeJS
# * A recent version of the standard Ruby runtime to use by default
# * The bundler gem
FROM gcr.io/google_appengine/ruby

# Install 2.2.3
 if not already preinstalled by the base image
RUN cd /rbenv/plugins/ruby-build && \
    git pull && \
    rbenv install -s 2.2.3
 && \
    rbenv global 2.2.3
 && \
    gem install -q --no-rdoc --no-ri bundler --version 1.11
ENV RBENV_VERSION 2.2.3


# Copy the application files.
COPY . /app/

# Install required gems.
RUN bundle install --deployment && rbenv rehash

# BUG: Reset entrypoint to override base image.
ENTRYPOINT []

# Start application on port $PORT.
CMD bundle exec rackup -p 8080 -E production config.ru
+ docker build --tag us.gcr.io/cloud-compute-rails/appengine/default.20160427t004918:latest /workspace
Sending build context to Docker daemon 545.3 kB
Step 1 : FROM gcr.io/google_appengine/ruby
 ---> 3e6d0d6d0575
Step 2 : IF
Unknown instruction: IF
ERROR
ERROR: build step "gcr.io/cloud-builders/dockerizer" failed: exit status 1
ERROR: (gcloud.preview.app.deploy) Error Response: [2] Build failed; check build logs for details

任何线索?

2 个答案:

答案 0 :(得分:3)

  1. 修复第一个(如果应用程序中没有dockerfile,应该自动生成。)

    转到您未能部署的ruby示例文件。 (我的是“2-cloud-sql”,如下所示)

    $ cd 2-cloud-sql

  2. 我执行了下一个命令。

    $ gcloud preview app gen-config --custom
    

    如果您质疑“立即更新?”回答y(是)。 然后“app.yaml”文件变为自定义但原始文件保持为书面状态,并且“dockerfile”被创建。

    接下来我被要求更新一些Cloud SDK组件,因此请在下面写下命令。

    $ gcloud components update
    

    我在下面做了

    $ bundle install
    
    1. 您的示例应用中应该已经存在“Dockerfile”。 打开然后看。
    2. 在我的情况下,这3个地方(黄色方块)缩进并不自然地进入下一行.~但是在另一个谷歌教程中,没有这么奇怪的一行,所以在这种情况下我不需要更改“dockerfile” 。请参阅dockerfile并检查是否有更改的地方如下所示.~

      Go and check a picture

      所以我修好了这些奇怪的部分。

      Here is a picture

      在“如果”之前,线路发生了奇怪的变化,并且在“&& \”之前。

      修复并保存Dockerfile后

      我执行了像google指令这样的命令。

      $ RAILS_ENV=production rake assets:precompile
      
      
      $ gcloud preview app deploy
      

      这就是我所做的一切,我希望它对你有所帮助。

答案 1 :(得分:0)

我遇到了与你相同的问题并修复了它。

就我而言,有两点需要解决。

  1. Dockerfile已经消失。(你的样本中是否有Dockerfile下载?)
  2. 在Dockerfile中有奇怪的缩进。(也许这会导致ruby版本的差异。)
  3. 通过修正这两点,它起作用了。

    我将详细介绍此程序。