我正在尝试更符合成本效益的方法来部署我的Rails应用程序,并通过Ruby初学者项目来体验Google平台。
它几乎是完美的,当然在价格上也很有竞争力,但是部署非常缓慢。
当我从样例书架应用程序运行部署命令时
$ gcloud preview app deploy app.yaml worker.yaml --promote我可以在gae-builder-vm上看到一个新的计算引擎/VM实例页实例,并得到熟悉的Docker构建输出 --这大约需要10分钟才能完成。
但是,如果我立即重新部署,我就会得到一个新的gae-builder-vm,它可以通过完全相同的10分钟的构建过程,从第一次生成映像时就没有明显的缓存。完成。
在这两种情况下,第二个模块(worker.yaml)被缓存,并且运行得非常快:
Building and pushing image for module [worker]
---------------------------------------- DOCKER BUILD OUTPUT ----------------------------------------
Step 0 : FROM gcr.io/google_appengine/ruby
---> 3e8b286df835
Step 1 : RUN rbenv install -s 2.2.3 && rbenv global 2.2.3 && gem install -q --no-rdoc --no-ri bundler --version 1.10.6 && gem install -q --no-rdoc --no-ri foreman --version 0.78.0
---> Using cache
---> efdafde40bf8
Step 2 : ENV RBENV_VERSION 2.2.3
---> Using cache
---> 49534db5b7eb
Step 3 : COPY Gemfile Gemfile.lock /app/
---> Using cache
---> d8c2f1c5a44b
Step 4 : RUN bundle install && rbenv rehash
---> Using cache
---> d9f9b57ccbad
Step 5 : COPY . /app/
---> Using cache
---> 503904327f13
Step 6 : ENTRYPOINT bundle exec foreman start --formation "$FORMATION"
---> Using cache
---> af547f521411
Successfully built af547f521411但是,如果没有任何变化,在部署之间不能缓存这些版本对我来说是没有意义的。
理想情况下,如果我在专用构建服务器(它可以记住构建之间的Docker映像)上启动重建,然后更新一个公共映像文件,并要求Google使用预构建的映像重新部署,这会更快。
下面是由gcloud生成的Docker文件
# This Dockerfile for a Ruby application was generated by gcloud with:
# gcloud preview app gen-config --custom
# 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 and foreman gems
FROM gcr.io/google_appengine/ruby
# Install ruby 2.2.3 if not already preinstalled by the base image
# base image: https://github.com/GoogleCloudPlatform/ruby-docker/blob/master/appengine/Dockerfile
# preinstalled ruby versions: 2.0.0-p647 2.1.7 2.2.3
RUN rbenv install -s 2.2.3 && \
rbenv global 2.2.3 && \
gem install -q --no-rdoc --no-ri bundler --version 1.10.6 && \
gem install -q --no-rdoc --no-ri foreman --version 0.78.0
ENV RBENV_VERSION 2.2.3
# To install additional packages needed by your gems, uncomment
# the "RUN apt-get update" and "RUN apt-get install" lines below
# and specify your packages.
# RUN apt-get update
# RUN apt-get install -y -q (your packages here)
# Install required gems.
COPY Gemfile Gemfile.lock /app/
RUN bundle install && rbenv rehash
# Start application on port 8080.
COPY . /app/
ENTRYPOINT bundle exec foreman start --formation "$FORMATION"我怎样才能使这个过程更快?
发布于 2016-04-17 13:31:05
嗯,你把两个不同的案子混为一谈:
更新:我之前忽略了您的观点,在仔细查看您的两条日志时,我同意您的意见,即缓存似乎是每个构建VM的本地缓存(仅在构建worker模块时才解释缓存命中,每个缓存都位于预先构建相应的default模块的同一个VM上),因此不会在部署中重复使用。
另一个更新:可能有一种方法可以跨部署获得缓存命中.
描述表示宿主构建也可以使用Container (它似乎是,默认设置为!)完成。除了临时VM之外:
若要使用临时VM (使用默认的- docker -build=remote设置),而不是使用执行坞构建,请运行: $ gcloud配置集应用程序/use_cloud_build
使用容器生成器API完成的构建可能使用共享存储,这可能允许跨部署的缓存命中。值得一试。
https://stackoverflow.com/questions/34500213
复制相似问题