Created
September 6, 2018 08:58
-
-
Save gottfrois/6cde72b0cd61df1a8282057e4e784339 to your computer and use it in GitHub Desktop.
medium-multi-stage-dockerfile-bundler-stage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###################### | |
# Stage: bundler | |
FROM ruby as bundler | |
LABEL description="Install and cache gems for all environments" | |
WORKDIR /home/app | |
# Copy the Gemfile and Gemfile.lock | |
COPY Gemfile* /home/app/ | |
# Install build deps as virtual dependencies. | |
# | |
# - build-base -- used to install gcc, make, etc. | |
# - libxml2-dev -- used to install nokogiri native extension | |
# - libxslt-dev -- used to install nokogiri native extension | |
RUN apk add --update --no-cache --virtual .build-deps \ | |
build-base \ | |
libxml2-dev \ | |
libxslt-dev \ | |
&& bundle config build.nokogiri --use-system-libraries \ | |
&& bundle install --frozen --deployment --jobs 4 --retry 3 \ | |
# Remove unneeded files (*/.git, *.o, *.c) but keeps cached gems for later stages | |
&& find vendor/bundle/ -name ".git" -exec rm -rv {} + \ | |
&& find vendor/bundle/ -name "*.c" -delete \ | |
&& find vendor/bundle/ -name "*.o" -delete \ | |
&& rm -rf vendor/bundle/ruby/*/cache \ | |
# Remove unneeded build deps | |
&& apk del .build-deps |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment