You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 19, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Apr 19, 2026. It is now read-only.
I noticed that every time I run gcloud app deploy, bundle install will be execute, and it will refeching gems and install them again, even the ruby version and Gemfile.lock are not updated.
Wondering if there is a way for us to reuse the gems we fetched before, so that it can speed up the deployments.
I can do it via cloud build by adding following docker file in my repo as ruby-base.dockerfile:
# This file is generated base on generate-dockerfile from follow repo:# https://github.com/GoogleCloudPlatform/ruby-docker/tree/master/ruby-generate-dockerfileARG ruby_version=2.6.4
ARG prebuilt_image=gcr.io/gcp-runtimes/ruby/ubuntu16/prebuilt/ruby-2.6.4:latest
FROM $prebuilt_image as prebuilt-ruby
FROM gcr.io/gcp-runtimes/ruby/ubuntu16:latest AS augmented-base
ARG ruby_version=2.6.4
ARG bundler_version=2.0.2
ARG rails_env=production
## Commonly installed gems (e.g. bundler) are available from this image.COPY --from=gcr.io/gcp-runtimes/ruby/ubuntu16/build-tools:latest /opt/gems/ /opt/gems/
## Install Ruby ${ruby_version} from a prebuilt image. If a prebuilt image## is not available, use the alternate installation method commented below.COPY --from=prebuilt-ruby \
/opt/rbenv/versions/${ruby_version} \
/opt/rbenv/versions/${ruby_version}
RUN echo "This is the ruby version ${ruby_version}"RUN rbenv global $ruby_version \
&& rbenv rehash \
&& (gem install /opt/gems/bundler-${bundler_version}.gem ; \
rbenv rehash);
## Alternate installation for Ruby versions that have no prebuilt image.# RUN if [ ! -x ${RBENV_ROOT}/versions/${ruby_version}/bin/ruby ]; \# then \# cd ${RBENV_ROOT}/plugins/ruby-build \# && git pull \# && rbenv install -s ${ruby_version} \# && rbenv global ${ruby_version} \# && rbenv rehash \# && (gem install /opt/gems/bundler-${bundler_version}.gem ; \# rbenv rehash); \# fiCOPY ./Gemfile /app/
COPY ./Gemfile.lock /app/
RUN bundle install --deployment && rbenv rehash
ENTRYPOINT []
Activity
RSpace commentedon Jan 3, 2019
+1
leomao10 commentedon Sep 8, 2020
I can do it via cloud build by adding following docker file in my repo as ruby-base.dockerfile:
Then in
cloudbuild.ymlfile, I added this step:leomao10 commentedon Sep 8, 2020
But of course, we still reinstall the gems when
Gemfile.lockis not changed. Might need to take idea from this blogpost for yarn cache:https://medium.com/hackernoon/using-yarn-with-docker-c116ad289d56