Dockerfile: allow Docker to cache build steps (#1336)

- 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 <matt.peveler@gmail.com>
This commit is contained in:
Michael Bang
2020-10-26 19:31:15 +01:00
committed by GitHub
parent de961f53ad
commit 779658de7b

View File

@@ -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 \
@@ -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"]