From f9a2625e38d17238b61b3eb084d84da2a1a4ea66 Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Fri, 17 Oct 2014 18:26:08 -0600 Subject: [PATCH] Simplify bundler config so "bundle install" does the right thing by default --- 1.9/Dockerfile | 12 ++++++++++-- 1.9/onbuild/Dockerfile | 11 +++++++---- 2.0/Dockerfile | 12 ++++++++++-- 2.0/onbuild/Dockerfile | 11 +++++++---- 2.1/Dockerfile | 12 ++++++++++-- 2.1/onbuild/Dockerfile | 11 +++++++---- 6 files changed, 51 insertions(+), 18 deletions(-) diff --git a/1.9/Dockerfile b/1.9/Dockerfile index 00a4be645..2d10ad97e 100644 --- a/1.9/Dockerfile +++ b/1.9/Dockerfile @@ -22,8 +22,16 @@ RUN apt-get update \ && rm -r /usr/src/ruby # skip installing gem documentation -RUN echo 'gem: --no-rdoc --no-ri' >> /.gemrc +RUN echo 'gem: --no-rdoc --no-ri' >> "$HOME/.gemrc" -RUN gem install bundler +# install things globally, for great justice +ENV GEM_HOME /usr/local/bundle +ENV PATH $GEM_HOME/bin:$PATH +RUN gem install bundler \ + && bundle config --global path "$GEM_HOME" \ + && bundle config --global bin "$GEM_HOME/bin" + +# don't create ".bundle" in all our apps +ENV BUNDLE_APP_CONFIG $GEM_HOME CMD [ "irb" ] diff --git a/1.9/onbuild/Dockerfile b/1.9/onbuild/Dockerfile index ed4edd70a..1a31d93d7 100644 --- a/1.9/onbuild/Dockerfile +++ b/1.9/onbuild/Dockerfile @@ -1,10 +1,13 @@ FROM ruby:1.9.3-p547 +# throw errors if Gemfile has been modified since Gemfile.lock +RUN bundle config --global frozen 1 + RUN mkdir -p /usr/src/app WORKDIR /usr/src/app -ONBUILD ADD Gemfile /usr/src/app/ -ONBUILD ADD Gemfile.lock /usr/src/app/ -ONBUILD RUN bundle install --system +ONBUILD COPY Gemfile /usr/src/app/ +ONBUILD COPY Gemfile.lock /usr/src/app/ +ONBUILD RUN bundle install -ONBUILD ADD . /usr/src/app +ONBUILD COPY . /usr/src/app diff --git a/2.0/Dockerfile b/2.0/Dockerfile index 4557e2d75..ba84a4c78 100644 --- a/2.0/Dockerfile +++ b/2.0/Dockerfile @@ -22,8 +22,16 @@ RUN apt-get update \ && rm -r /usr/src/ruby # skip installing gem documentation -RUN echo 'gem: --no-rdoc --no-ri' >> /.gemrc +RUN echo 'gem: --no-rdoc --no-ri' >> "$HOME/.gemrc" -RUN gem install bundler +# install things globally, for great justice +ENV GEM_HOME /usr/local/bundle +ENV PATH $GEM_HOME/bin:$PATH +RUN gem install bundler \ + && bundle config --global path "$GEM_HOME" \ + && bundle config --global bin "$GEM_HOME/bin" + +# don't create ".bundle" in all our apps +ENV BUNDLE_APP_CONFIG $GEM_HOME CMD [ "irb" ] diff --git a/2.0/onbuild/Dockerfile b/2.0/onbuild/Dockerfile index 2a5724eff..e3d65179c 100644 --- a/2.0/onbuild/Dockerfile +++ b/2.0/onbuild/Dockerfile @@ -1,10 +1,13 @@ FROM ruby:2.0.0-p576 +# throw errors if Gemfile has been modified since Gemfile.lock +RUN bundle config --global frozen 1 + RUN mkdir -p /usr/src/app WORKDIR /usr/src/app -ONBUILD ADD Gemfile /usr/src/app/ -ONBUILD ADD Gemfile.lock /usr/src/app/ -ONBUILD RUN bundle install --system +ONBUILD COPY Gemfile /usr/src/app/ +ONBUILD COPY Gemfile.lock /usr/src/app/ +ONBUILD RUN bundle install -ONBUILD ADD . /usr/src/app +ONBUILD COPY . /usr/src/app diff --git a/2.1/Dockerfile b/2.1/Dockerfile index 88ebdd398..92e983400 100644 --- a/2.1/Dockerfile +++ b/2.1/Dockerfile @@ -22,8 +22,16 @@ RUN apt-get update \ && rm -r /usr/src/ruby # skip installing gem documentation -RUN echo 'gem: --no-rdoc --no-ri' >> /.gemrc +RUN echo 'gem: --no-rdoc --no-ri' >> "$HOME/.gemrc" -RUN gem install bundler +# install things globally, for great justice +ENV GEM_HOME /usr/local/bundle +ENV PATH $GEM_HOME/bin:$PATH +RUN gem install bundler \ + && bundle config --global path "$GEM_HOME" \ + && bundle config --global bin "$GEM_HOME/bin" + +# don't create ".bundle" in all our apps +ENV BUNDLE_APP_CONFIG $GEM_HOME CMD [ "irb" ] diff --git a/2.1/onbuild/Dockerfile b/2.1/onbuild/Dockerfile index 8c9a61ae5..82c222dd8 100644 --- a/2.1/onbuild/Dockerfile +++ b/2.1/onbuild/Dockerfile @@ -1,10 +1,13 @@ FROM ruby:2.1.3 +# throw errors if Gemfile has been modified since Gemfile.lock +RUN bundle config --global frozen 1 + RUN mkdir -p /usr/src/app WORKDIR /usr/src/app -ONBUILD ADD Gemfile /usr/src/app/ -ONBUILD ADD Gemfile.lock /usr/src/app/ -ONBUILD RUN bundle install --system +ONBUILD COPY Gemfile /usr/src/app/ +ONBUILD COPY Gemfile.lock /usr/src/app/ +ONBUILD RUN bundle install -ONBUILD ADD . /usr/src/app +ONBUILD COPY . /usr/src/app