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 # NOTE: we don't purge gcc below as we have some places in the OE metadata that look for it
COPY requirements.txt / COPY requirements.txt /
RUN apt-get update RUN apt-get update \
RUN apt-get install -y --no-install-recommends \ && apt-get install -y --no-install-recommends \
autoconf \ autoconf \
g++ \ g++ \
gcc \ gcc \
@ -34,20 +34,20 @@ RUN apt-get install -y --no-install-recommends \
netcat-openbsd \ netcat-openbsd \
curl \ curl \
git-core \ git-core \
vim vim \
RUN echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen \ && echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen \
&& locale-gen en_US.UTF-8 \ && locale-gen en_US.UTF-8 \
&& update-locale && update-locale \
RUN pip install --upgrade pip && pip3 install gunicorn \
RUN pip3 install gunicorn && pip install setuptools \
RUN pip install setuptools && pip3 install setuptools \
RUN pip3 install setuptools && pip install -r /requirements.txt \
RUN pip install -r /requirements.txt && pip3 install -r /requirements.txt \
RUN pip3 install -r /requirements.txt && apt-get purge -y autoconf g++ make python-dev python3-dev libjpeg-dev libmariadbclient-dev \
RUN apt-get purge -y autoconf g++ make python3-dev libjpeg-dev libmariadbclient-dev \
&& apt-get autoremove -y \ && apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/* \ && rm -rf /var/lib/apt/lists/* \
&& apt-get clean && apt-get clean
COPY . /opt/layerindex COPY . /opt/layerindex
COPY docker/settings.py /opt/layerindex/settings.py COPY docker/settings.py /opt/layerindex/settings.py
COPY docker/refreshlayers.sh /opt/refreshlayers.sh COPY docker/refreshlayers.sh /opt/refreshlayers.sh