Skip to content

Commit

Permalink
Dockerfile: allow Docker to cache build steps (#1336)
Browse files Browse the repository at this point in the history
- By having a `COPY . xx` step before installing dependencies, we rob
Docker of the opportunity to cache downloading and building dependencies
if we make any changes to any files in the repository. By copying only
Gemfiles before the build step, we only require Docker to rebuild
dependencies when the Gemfiles have changed.

Co-authored-by: Matthew Peveler <[email protected]>
  • Loading branch information
micvbang and MasterOdin authored Oct 26, 2020
1 parent de961f5 commit 779658d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ VOLUME /srv/slate/source

EXPOSE 4567

COPY . /srv/slate
COPY Gemfile .
COPY Gemfile.lock .

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
Expand All @@ -17,8 +18,11 @@ RUN apt-get update \
&& bundle install \
&& apt-get remove -y build-essential \
&& apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/* \
&& chmod +x /srv/slate/slate.sh
&& rm -rf /var/lib/apt/lists/*

COPY . /srv/slate

RUN chmod +x /srv/slate/slate.sh

ENTRYPOINT ["/srv/slate/slate.sh"]
CMD ["build"]

0 comments on commit 779658d

Please sign in to comment.