Skip to content

Commit 591c56e

Browse files
authored
Merge pull request #153 from fly-apps/make-parallelize
Use MAKE="make -j$(nproc)" to speed up bundle install step
2 parents fe921e8 + 41e1406 commit 591c56e

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ different contents. If both are specified, `--force` takes precedence.
4444

4545
* `--cache` - use build caching to speed up builds
4646
* `--parallel` - use multi-stage builds to install gems and node modules in parallel
47+
* `--nproc n` - run bundle install in parallel
4748

4849
### Add/remove a Feature:
4950

lib/generators/dockerfile_generator.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class DockerfileGenerator < Rails::Generators::Base
2727
"mysql" => false,
2828
"nginx" => false,
2929
"parallel" => false,
30+
"nproc" => 1,
3031
"passenger" => false,
3132
"platform" => nil,
3233
"postgresql" => false,
@@ -148,6 +149,9 @@ class DockerfileGenerator < Rails::Generators::Base
148149
class_option :parallel, type: :boolean, default: OPTION_DEFAULTS.parallel,
149150
desc: "use build stages to install gems and node modules in parallel"
150151

152+
class_option :nproc, type: :numeric, default: OPTION_DEFAULTS.nproc,
153+
desc: "run bundle install in parallel"
154+
151155
class_option :swap, type: :string, default: OPTION_DEFAULTS.swap,
152156
desc: "allocate swapspace"
153157

lib/generators/templates/Dockerfile.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ ENV <%= build_env.join(" \\\n ") %>
9696
<% end -%>
9797
# Install application gems
9898
COPY<% if options.link? %> --link<% end %> Gemfile Gemfile.lock <% if references_ruby_version_file? %><%= ruby_version_file %> <% end %>./
99+
<% if options.nproc > 1 -%>
100+
ENV MAKE="make -j<%= options.nproc %>"
101+
<% end -%>
99102
<% if @netpopbug && Rails.env != "test" -%>
100103
RUN sed -i "/net-pop (0.1.2)/a\ net-protocol" Gemfile.lock
101104
<% end -%>

0 commit comments

Comments
 (0)