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 <Konrad.Scherer@windriver.com>
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
This commit is contained in:
Konrad Scherer 2018-07-11 12:19:15 -04:00 committed by Paul Eggleton
parent 272f0eded2
commit 65d058237f

View File

@ -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