Took me a while to figure out how to get this running without installing ruby-dev or tools to compile native extensions, keeping my container nice and small.
Updated: using builtin packages for bundler + io-console now since they are smaller then installing manually and the logic is simpler
(apk add –update ruby ruby-io-console ruby-bundler)
… if latest bundler is needed below Dockerfile might still be useful.
FROM alpine RUN apk add --update ruby && rm -rf /var/cache/apk/* ENV BUNDLER_VERSION 1.12.3 RUN gem install bundler -v $BUNDLER_VERSION --no-ri --no-rdoc # bundler wants some library that needs core extensions ... but it won't compile RUN mkdir /usr/lib/ruby/gems/2.2.0/gems/bundler-$BUNDLER_VERSION/lib/io RUN touch /usr/lib/ruby/gems/2.2.0/gems/bundler-$BUNDLER_VERSION/lib/io/console.rb # bundler does not want to install as root RUN bundle config --global silence_root_warning 1 RUN mkdir /app WORKDIR /app ADD Gemfile . ADD Gemfile.lock . RUN bundle
One thought on “Bundler / Docker / alpine for a super small container”
You may consider using ARG instead of ENV, see: https://docs.docker.com/engine/reference/builder/#arg