On 07/10/2018 12:17 PM, Paul Eggleton wrote:
Hi folks

I've been trying to get the OE layer index example docker setup in shape,
based upon improvements from myself, Michael and Konrad. For the moment I've
taken most of what Michael and I did (with some fixes and tweaks, and broken up
into smaller patches) and a few pieces of the Dockerfile from Konrad's recent
patch and put it here:


Konrad, I know you were a little bit more ambitious with your changes but I
wanted to get something closer to what Michael is using and then we can build
upon it. In particular I haven't yet explored docker-compose as you have,
although it looks like it would make deploying all of this a bit easier.

Let me know what you think.

Hello Paul,

I have attached a patch to reduce the layerindex-web image size further. Docker image layers are like git objects and RUN commands can only hide files, not remove them once they have been committed. The pip upgrade caused the following 'pip install' to fail and was removed.

I recommend docker-compose because much of the information in docker/README can be captured in a compose yaml file. It handles the network setup and makes managing shared volumes much simpler.

Konrad Scherer, MTS, Linux Products Group, Wind River
>From 22274ea8298b4cb0c8ea3e545367a9c2c4c379c4 Mon Sep 17 00:00:00 2001
From: Konrad Scherer <konrad.sche...@windriver.com>
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 <konrad.sche...@windriver.com>
 Dockerfile | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index 523280d..0aff2ec 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -12,8 +12,8 @@ ENV PYTHONUNBUFFERED=1 \
 #ENV https_proxy https://your.proxy.server:port
 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 \
@@ -31,20 +31,20 @@ RUN apt-get install -y --no-install-recommends \
 	locales \
 	netcat-openbsd \
 	curl \
-	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++ gcc 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++ gcc 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

yocto mailing list

Reply via email to