From 65d058237f96a151c913a70ba4d639c7aa0fb0b5 Mon Sep 17 00:00:00 2001 From: Konrad Scherer Date: Wed, 11 Jul 2018 12:19:15 -0400 Subject: [PATCH] Dockerfile: Reduce image size by merging RUN stages together Docker commits changes after each RUN stage and commands that delete files must part of the sane RUN command to actually reduce image size. Debian stretch contains pip 9.0.3 and the upgrade to 10 caused pip install to fail. Signed-off-by: Konrad Scherer Signed-off-by: Paul Eggleton --- Dockerfile | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index f8fdd2b..107b347 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,8 +14,8 @@ ENV PYTHONUNBUFFERED=1 \ # NOTE: we don't purge gcc below as we have some places in the OE metadata that look for it COPY requirements.txt / -RUN apt-get update -RUN apt-get install -y --no-install-recommends \ +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ autoconf \ g++ \ gcc \ @@ -34,20 +34,20 @@ RUN apt-get install -y --no-install-recommends \ netcat-openbsd \ curl \ git-core \ - vim -RUN echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen \ + vim \ + && echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen \ && locale-gen en_US.UTF-8 \ - && update-locale -RUN pip install --upgrade pip -RUN pip3 install gunicorn -RUN pip install setuptools -RUN pip3 install setuptools -RUN pip install -r /requirements.txt -RUN pip3 install -r /requirements.txt -RUN apt-get purge -y autoconf g++ make python3-dev libjpeg-dev libmariadbclient-dev \ + && update-locale \ + && pip3 install gunicorn \ + && pip install setuptools \ + && pip3 install setuptools \ + && pip install -r /requirements.txt \ + && pip3 install -r /requirements.txt \ + && apt-get purge -y autoconf g++ make python-dev python3-dev libjpeg-dev libmariadbclient-dev \ && apt-get autoremove -y \ && rm -rf /var/lib/apt/lists/* \ && apt-get clean + COPY . /opt/layerindex COPY docker/settings.py /opt/layerindex/settings.py COPY docker/refreshlayers.sh /opt/refreshlayers.sh