Skip to content

Commit 7663560

Browse files
committed
Skip pip's default caching behavior
This caching includes the file that was downloaded over http, as well as this new wheel cache. Neither of which are valuable and just add bloat into the resulting images. Similar to removing the apt caches on disk at each layer. This also makes pip install's a tiny bit faster since pip avoids trying to automatically create wheels (which is fast itself, but again, unnecessary in this world). See: - https://pip.pypa.io/en/latest/reference/pip_install.html#caching - https://pip.pypa.io/en/latest/reference/pip_install.html#wheel-cache
1 parent 38e00bb commit 7663560

File tree

16 files changed

+19
-19
lines changed

16 files changed

+19
-19
lines changed

2.7/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ RUN set -x \
2828
&& make install \
2929
&& ldconfig \
3030
&& curl -SL 'https://bootstrap.pypa.io/get-pip.py' | python2 \
31-
&& pip install --upgrade pip==$PYTHON_PIP_VERSION \
31+
&& pip install --no-cache-dir --upgrade pip==$PYTHON_PIP_VERSION \
3232
&& find /usr/local \
3333
\( -type d -a -name test -o -name tests \) \
3434
-o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \
3535
-exec rm -rf '{}' + \
3636
&& rm -rf /usr/src/python
3737

3838
# install "virtualenv", since the vast majority of users of this image will want it
39-
RUN pip install virtualenv
39+
RUN pip install --no-cache-dir virtualenv
4040

4141
CMD ["python2"]

2.7/onbuild/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ RUN mkdir -p /usr/src/app
44
WORKDIR /usr/src/app
55

66
ONBUILD COPY requirements.txt /usr/src/app/
7-
ONBUILD RUN pip install -r requirements.txt
7+
ONBUILD RUN pip install --no-cache-dir -r requirements.txt
88

99
ONBUILD COPY . /usr/src/app

2.7/slim/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ RUN set -x \
3636
&& make install \
3737
&& ldconfig \
3838
&& curl -SL 'https://bootstrap.pypa.io/get-pip.py' | python2 \
39-
&& pip install --upgrade pip==$PYTHON_PIP_VERSION \
39+
&& pip install --no-cache-dir --upgrade pip==$PYTHON_PIP_VERSION \
4040
&& find /usr/local \
4141
\( -type d -a -name test -o -name tests \) \
4242
-o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \
@@ -45,6 +45,6 @@ RUN set -x \
4545
&& rm -rf /usr/src/python
4646

4747
# install "virtualenv", since the vast majority of users of this image will want it
48-
RUN pip install virtualenv
48+
RUN pip install --no-cache-dir virtualenv
4949

5050
CMD ["python2"]

2.7/wheezy/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ RUN set -x \
2828
&& make install \
2929
&& ldconfig \
3030
&& curl -SL 'https://bootstrap.pypa.io/get-pip.py' | python2 \
31-
&& pip install --upgrade pip==$PYTHON_PIP_VERSION \
31+
&& pip install --no-cache-dir --upgrade pip==$PYTHON_PIP_VERSION \
3232
&& find /usr/local \
3333
\( -type d -a -name test -o -name tests \) \
3434
-o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \
3535
-exec rm -rf '{}' + \
3636
&& rm -rf /usr/src/python
3737

3838
# install "virtualenv", since the vast majority of users of this image will want it
39-
RUN pip install virtualenv
39+
RUN pip install --no-cache-dir virtualenv
4040

4141
CMD ["python2"]

3.2/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ RUN set -x \
2828
&& make install \
2929
&& ldconfig \
3030
&& curl -SL 'https://bootstrap.pypa.io/get-pip.py' | python3 \
31-
&& pip install --upgrade pip==$PYTHON_PIP_VERSION \
31+
&& pip install --no-cache-dir --upgrade pip==$PYTHON_PIP_VERSION \
3232
&& find /usr/local \
3333
\( -type d -a -name test -o -name tests \) \
3434
-o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \

3.2/onbuild/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ RUN mkdir -p /usr/src/app
44
WORKDIR /usr/src/app
55

66
ONBUILD COPY requirements.txt /usr/src/app/
7-
ONBUILD RUN pip install -r requirements.txt
7+
ONBUILD RUN pip install --no-cache-dir -r requirements.txt
88

99
ONBUILD COPY . /usr/src/app

3.2/slim/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ RUN set -x \
3636
&& make install \
3737
&& ldconfig \
3838
&& curl -SL 'https://bootstrap.pypa.io/get-pip.py' | python3 \
39-
&& pip install --upgrade pip==$PYTHON_PIP_VERSION \
39+
&& pip install --no-cache-dir --upgrade pip==$PYTHON_PIP_VERSION \
4040
&& find /usr/local \
4141
\( -type d -a -name test -o -name tests \) \
4242
-o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \

3.2/wheezy/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ RUN set -x \
2828
&& make install \
2929
&& ldconfig \
3030
&& curl -SL 'https://bootstrap.pypa.io/get-pip.py' | python3 \
31-
&& pip install --upgrade pip==$PYTHON_PIP_VERSION \
31+
&& pip install --no-cache-dir --upgrade pip==$PYTHON_PIP_VERSION \
3232
&& find /usr/local \
3333
\( -type d -a -name test -o -name tests \) \
3434
-o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \

3.3/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ RUN set -x \
2828
&& make install \
2929
&& ldconfig \
3030
&& curl -SL 'https://bootstrap.pypa.io/get-pip.py' | python3 \
31-
&& pip install --upgrade pip==$PYTHON_PIP_VERSION \
31+
&& pip install --no-cache-dir --upgrade pip==$PYTHON_PIP_VERSION \
3232
&& find /usr/local \
3333
\( -type d -a -name test -o -name tests \) \
3434
-o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \

3.3/onbuild/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ RUN mkdir -p /usr/src/app
44
WORKDIR /usr/src/app
55

66
ONBUILD COPY requirements.txt /usr/src/app/
7-
ONBUILD RUN pip install -r requirements.txt
7+
ONBUILD RUN pip install --no-cache-dir -r requirements.txt
88

99
ONBUILD COPY . /usr/src/app

3.3/slim/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ RUN set -x \
3636
&& make install \
3737
&& ldconfig \
3838
&& curl -SL 'https://bootstrap.pypa.io/get-pip.py' | python3 \
39-
&& pip install --upgrade pip==$PYTHON_PIP_VERSION \
39+
&& pip install --no-cache-dir --upgrade pip==$PYTHON_PIP_VERSION \
4040
&& find /usr/local \
4141
\( -type d -a -name test -o -name tests \) \
4242
-o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \

3.3/wheezy/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ RUN set -x \
2828
&& make install \
2929
&& ldconfig \
3030
&& curl -SL 'https://bootstrap.pypa.io/get-pip.py' | python3 \
31-
&& pip install --upgrade pip==$PYTHON_PIP_VERSION \
31+
&& pip install --no-cache-dir --upgrade pip==$PYTHON_PIP_VERSION \
3232
&& find /usr/local \
3333
\( -type d -a -name test -o -name tests \) \
3434
-o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \

3.4/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ RUN set -x \
2727
&& make -j$(nproc) \
2828
&& make install \
2929
&& ldconfig \
30-
&& pip3 install --upgrade pip==$PYTHON_PIP_VERSION \
30+
&& pip3 install --no-cache-dir --upgrade pip==$PYTHON_PIP_VERSION \
3131
&& find /usr/local \
3232
\( -type d -a -name test -o -name tests \) \
3333
-o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \

3.4/onbuild/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ RUN mkdir -p /usr/src/app
44
WORKDIR /usr/src/app
55

66
ONBUILD COPY requirements.txt /usr/src/app/
7-
ONBUILD RUN pip install -r requirements.txt
7+
ONBUILD RUN pip install --no-cache-dir -r requirements.txt
88

99
ONBUILD COPY . /usr/src/app

3.4/slim/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ RUN set -x \
3535
&& make -j$(nproc) \
3636
&& make install \
3737
&& ldconfig \
38-
&& pip3 install --upgrade pip==$PYTHON_PIP_VERSION \
38+
&& pip3 install --no-cache-dir --upgrade pip==$PYTHON_PIP_VERSION \
3939
&& find /usr/local \
4040
\( -type d -a -name test -o -name tests \) \
4141
-o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \

3.4/wheezy/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ RUN set -x \
2727
&& make -j$(nproc) \
2828
&& make install \
2929
&& ldconfig \
30-
&& pip3 install --upgrade pip==$PYTHON_PIP_VERSION \
30+
&& pip3 install --no-cache-dir --upgrade pip==$PYTHON_PIP_VERSION \
3131
&& find /usr/local \
3232
\( -type d -a -name test -o -name tests \) \
3333
-o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \

0 commit comments

Comments
 (0)