Skip to content

Commit c1f717f

Browse files
committed
[Dockerfile] Faster runs after local changes
This segments the portions of the `docker build` from ones that are more likely in between project file changes between test runs and ones that don't to reduce the re-build time when running tests via docker Context ------- So when you first run `rake test:docker:all` on a fresh install, you should expect this to take a bit since the docker cache isn't warmed and the steps of the image build process need to download items. You probably can expect this to take the sum total of about 10ish minutes the first time around. Some of this will be shared between versions of ruby (apt packages, installing `rvm`, etc.), but once you start installing specific versions of ruby, they images will diverge. That said, once you have gone through the build, subsequent runs with no changes take only about 10 seconds: $ rake test:docker ... real 0m10.660s user 0m0.819s sys 0m0.422s However, prior to this change, any file change made in the project dir required rebuilding everything installing bundler on. This ended up increasing the time to about a minute: $ rake test:docker ... real 1m10.171s user 0m0.668s sys 0m0.392s Changes ------- With this change, we push the bundling to happen in a separate directory from the final working dir, and only include the files necessary to perform that action. This decreases the time it takes to run the entire suite across all versions by 40 seconds: $ rake test:docker ... real 0m26.009s user 0m0.858s sys 0m0.464s We could further improve this by segmenting out the `rake build` steps, but for now I think this is an acceptable speed for most, and that is a slightly more complicated process to make that happen. Doing so would require not only moving the files we need just to compile done separately, but also moving the rest of the files that aren't involved with the C-extension separately.
1 parent fd4d447 commit c1f717f

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Dockerfile

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,17 @@ RUN curl -sSL https://get.rvm.io | bash -s
1414
ARG RVM_RUBY_VERSION=ruby-head
1515
RUN /bin/bash -l -c "echo $RVM_RUBY_VERSION"
1616
RUN /bin/bash -l -c ". /etc/profile.d/rvm.sh && rvm install $RVM_RUBY_VERSION --binary || rvm install $RVM_RUBY_VERSION"
17-
ADD . /stackprof/
18-
WORKDIR /stackprof/
17+
18+
# Gem Dependencies
1919
RUN /bin/bash -l -c ". /etc/profile.d/rvm.sh && gem install bundler:1.16.0"
20+
ADD Gemfile Gemfile.lock stackprof.gemspec /bundle/
21+
WORKDIR /bundle/
2022
RUN /bin/bash -l -c ". /etc/profile.d/rvm.sh && bundle install"
23+
24+
# Build Extension
25+
ADD . /stackprof/
26+
WORKDIR /stackprof/
2127
RUN /bin/bash -l -c ". /etc/profile.d/rvm.sh && bundle exec rake build"
22-
CMD /bin/bash -l -c ". /etc/profile.d/rvm.sh && bundle exec rake"
28+
29+
# Test
30+
CMD /bin/bash -l -c ". /etc/profile.d/rvm.sh && TESTOPTS='--seed=1355' bundle exec rake"

0 commit comments

Comments
 (0)