Skip to content

Instantly share code, notes, and snippets.

@inem
Last active May 8, 2020 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save inem/35d9be7f7f559803d808fb2090d4257c to your computer and use it in GitHub Desktop.
Save inem/35d9be7f7f559803d808fb2090d4257c to your computer and use it in GitHub Desktop.
Improving speed of docker builds with two Gemfiles
ansible
vendor/cache
log/*
tmp/cache/*
test
FROM ruby:2.6.4
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs vim
ENV PROJECT_ROOT /usr/src/app
RUN mkdir -p $PROJECT_ROOT
WORKDIR $PROJECT_ROOT
RUN gem install bundler:2.0.2
COPY .ruby-version Gemfile-native Gemfile-native.lock ./
RUN bundle install --without development test --gemfile=Gemfile-native
COPY Gemfile Gemfile.lock ./
RUN bundle install --without development test
COPY . .
CMD bin/rails s
# frozen_string_literal: true
ruby File.read('.ruby-version').strip
instance_eval File.read('Gemfile-native')
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.0.2', '>= 6.0.2.2'
# Use postgresql as the database for Active Record
gem 'pg', '>= 0.18', '< 2.0'
# Use Puma as the app server
gem 'puma', '~> 4.1'
# Use SCSS for stylesheets
gem 'sass-rails', '>= 6'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.7'
# Use Active Model has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Active Storage variant
# gem 'image_processing', '~> 1.2'
gem 'haml-rails'
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.2', require: false
group :development, :test do
gem 'dotenv-rails'
gem 'pry-byebug'
end
group :development do
gem 'listen', '>= 3.0.5', '< 3.2'
gem 'web-console', '>= 3.3.0'
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
group :test do
gem 'minitest-power_assert'
end
gem 'airbrake'
gem 'aws-sdk-s3'
gem 'dry-container'
gem 'haml'
gem 'metainspector'
gem 'oga'
gem 'persey'
gem 'redcarpet'
gem 'rubocop'
gem 'shufflino', '>= 0.3.2'
gem 'meta-tags'
gem 'rouge'
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby File.read('.ruby-version').strip
gem 'sassc', '2.2.1'
gem 'nokogiri', '1.10.9'
bundle:
bundle install
build:
docker build -t docker-experiment:two-gemfiles -f Dockerfile .
inspect:
docker images | head -n 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment