optimize size and time using --no-cache-dir
Using --no-cache-dir flag in pip install ,make sure dowloaded packages by pip don't cached on system . This is a best practise which make sure to fetch ftom repo instead of using local cached one . Further , in case of Docker Containers , by restricing caching , we can reduce image size. In term of stats , it depends upon the number of python packages multiplied by their respective size . e.g for heavy packages with a lot of dependencies it reduce a lot by don't caching pip packages. Further , more detail information can be found at https://medium.com/sciforce/strategies-of-docker-images-optimization-2ca9cc5719b6 Change-Id: Ice4040d8cc62494f8eab835631c5b0883656f812 Signed-off-by: Pratik Raj <rajpratik71@gmail.com>
This commit is contained in:
parent
ab0a85b605
commit
e95bf25db8
|
@ -7,11 +7,11 @@ RUN useradd -Ms /bin/bash qinling
|
|||
|
||||
RUN apt-get update && \
|
||||
apt-get -y install python-dev python-setuptools libffi-dev libxslt1-dev libxml2-dev libyaml-dev libssl-dev python-pip && \
|
||||
pip install -U pip setuptools uwsgi
|
||||
pip --no-cache-dir install -U pip setuptools uwsgi
|
||||
|
||||
COPY . /app
|
||||
WORKDIR /app
|
||||
RUN pip install --no-cache-dir -r requirements.txt && \
|
||||
RUN pip --no-cache-dir install -r requirements.txt && \
|
||||
chmod 0750 custom-entrypoint.sh && \
|
||||
mkdir /qinling_cgroup && \
|
||||
mkdir -p /var/lock/qinling && \
|
||||
|
|
|
@ -7,11 +7,11 @@ RUN useradd -Ms /bin/bash qinling
|
|||
|
||||
RUN apt-get update && \
|
||||
apt-get -y install python3-dev python3-setuptools libffi-dev libxslt1-dev libxml2-dev libyaml-dev libssl-dev python3-pip && \
|
||||
pip3 install -U pip setuptools uwsgi
|
||||
pip3 --no-cache-dir install -U pip setuptools uwsgi
|
||||
|
||||
COPY . /app
|
||||
WORKDIR /app
|
||||
RUN pip install --no-cache-dir -r requirements.txt && \
|
||||
RUN pip --no-cache-dir install -r requirements.txt && \
|
||||
chmod 0750 custom-entrypoint.sh && \
|
||||
mkdir /qinling_cgroup && \
|
||||
mkdir -p /var/lock/qinling && \
|
||||
|
|
|
@ -7,12 +7,12 @@ RUN adduser -HDs /bin/sh qinling
|
|||
|
||||
RUN apk update && \
|
||||
apk add --no-cache linux-headers build-base python2 python2-dev py2-pip uwsgi-python uwsgi-http && \
|
||||
pip install --upgrade pip && \
|
||||
pip --no-cache-dir install --upgrade pip && \
|
||||
rm -r /root/.cache
|
||||
|
||||
COPY . /sidecar
|
||||
WORKDIR /sidecar
|
||||
RUN pip install --no-cache-dir -r requirements.txt && \
|
||||
RUN pip --no-cache-dir install -r requirements.txt && \
|
||||
mkdir -p /var/lock/qinling && \
|
||||
mkdir -p /var/qinling/packages && \
|
||||
chown -R qinling:qinling /sidecar /var/lock/qinling /var/qinling/packages
|
||||
|
|
|
@ -23,9 +23,9 @@ RUN apt-get -qq update && \
|
|||
libuv1-dev && \
|
||||
curl -f -o /tmp/get-pip.py https://bootstrap.pypa.io/3.2/get-pip.py && \
|
||||
python /tmp/get-pip.py && rm /tmp/get-pip.py && \
|
||||
pip install --upgrade pip
|
||||
pip --no-cache-dir install --upgrade pip
|
||||
|
||||
RUN pip install pymysql psycopg2 py_mini_racer
|
||||
RUN pip --no-cache-dir install pymysql psycopg2 py_mini_racer
|
||||
|
||||
ENV QINLING_DIR="/opt/stack/qinling" \
|
||||
TMP_CONSTRAINTS="/tmp/upper-constraints.txt" \
|
||||
|
@ -44,11 +44,11 @@ COPY requirements.txt "${QINLING_DIR}/"
|
|||
RUN curl -o "${TMP_CONSTRAINTS}" \
|
||||
http://opendev.org/openstack/requirements/raw/branch/master/upper-constraints.txt && \
|
||||
sed -i "/^qinling.*/d" "${TMP_CONSTRAINTS}" && \
|
||||
pip install -r "${QINLING_DIR}/requirements.txt"
|
||||
pip --no-cache-dir install -r "${QINLING_DIR}/requirements.txt"
|
||||
|
||||
COPY . ${QINLING_DIR}
|
||||
|
||||
RUN pip install -e "${QINLING_DIR}" && \
|
||||
RUN pip --no-cache-dir install -e "${QINLING_DIR}" && \
|
||||
mkdir /etc/qinling && \
|
||||
rm -rf /var/lib/apt/lists/* && \
|
||||
find ${QINLING_DIR} -name "*.sh" -exec chmod +x {} \;
|
||||
|
|
Loading…
Reference in New Issue