From 94fe542dd71fc69aa8e88fa77db1860261a8ae13 Mon Sep 17 00:00:00 2001 From: Robert Sparks Date: Wed, 5 Jun 2019 12:45:12 -0500 Subject: [PATCH] Improved docker build correctness and build speed --- Dockerfile | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5c278a42..feaa915e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,6 @@ FROM opensuse/leap -RUN zypper -n update - -RUN zypper -n install \ +RUN zypper -n update && zypper -n install \ apache2 \ apache2-devel \ gcc \ @@ -18,6 +16,11 @@ EXPOSE 8001:8001 RUN mkdir /code WORKDIR /code + +# Doing this step before copying the whole codebase improves docker's ability to reuse cached layers at build time +COPY --chown=wwwrun:www ./requirements.txt /code/requirements.txt +RUN pip install -r requirements.txt + COPY --chown=wwwrun:www . /code/ RUN mkdir /code/static @@ -26,7 +29,6 @@ RUN chown wwwrun:www /code/static RUN mkdir /code/logs RUN chown wwwrun:www /code/logs -RUN pip install -r requirements.txt RUN echo "SECRET_KEY='garbage'" > ietf/settings/local.py ENV DJANGO_SETTINGS_MODULE=ietf.settings.production