From 332c58c82f9b07a6bdc638a35ad0de5bd4087261 Mon Sep 17 00:00:00 2001 From: Alvaro Enrique Ruano Date: Wed, 21 Nov 2018 02:27:43 -0600 Subject: [PATCH] Improve docker cache utilization on image construction (#1099) To provide better use of Docker cache during image build by installing from PIP before creating the layer with the source code (the PIP installations are less probable to change than the rest of the source code, so this layer will not be recreated with all the source code changes) This was previously discussed in #1094 --- Dockerfile | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 12b5d3e852..d4fb5130c7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,6 +35,22 @@ RUN apt-get update && \ ENV LC_ALL=C.UTF-8 \ DJANGO_SETTINGS_MODULE=production_settings +# To copy only the requirements files needed to install from PIP +COPY src/requirements /pretix/src/requirements +COPY src/requirements.txt /pretix/src +RUN pip3 install -U \ + pip \ + setuptools \ + wheel && \ + cd /pretix/src && \ + pip3 install \ + -r requirements.txt \ + -r requirements/memcached.txt \ + -r requirements/mysql.txt \ + -r requirements/redis.txt \ + gunicorn && \ + rm -rf ~/.cache/pip + COPY deployment/docker/pretix.bash /usr/local/bin/pretix COPY deployment/docker/supervisord.conf /etc/supervisord.conf COPY deployment/docker/nginx.conf /etc/nginx/nginx.conf @@ -43,18 +59,8 @@ COPY src /pretix/src RUN chmod +x /usr/local/bin/pretix && \ rm /etc/nginx/sites-enabled/default && \ - pip3 install -U \ - pip \ - setuptools \ - wheel && \ cd /pretix/src && \ rm -f pretix.cfg && \ - pip3 install \ - -r requirements.txt \ - -r requirements/memcached.txt \ - -r requirements/mysql.txt \ - -r requirements/redis.txt \ - gunicorn && \ mkdir -p data && \ chown -R pretixuser:pretixuser /pretix /data data && \ sudo -u pretixuser make production