Skip to content

Commit 031df18

Browse files
committed
Bind-mount Python patches instead of copying them to the image
We don't need the patches in runtime but because they're copied, they are still persisted in a layer of the image. Use bind-mount to have them available only for the build.
1 parent 8017f91 commit 031df18

19 files changed

+15
-15
lines changed

python/3.12/Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ ENV PATH=/usr/local/bin:$PATH
1414
# Set shell
1515
SHELL ["/bin/ash", "-o", "pipefail", "-c"]
1616

17-
COPY *.patch /usr/src/
18-
RUN set -ex \
17+
RUN \
18+
--mount=type=bind,source=./patches,target=/usr/src/patches \
19+
set -ex \
1920
&& export PYTHON_VERSION=${PYTHON_VERSION} \
2021
&& apk add --no-cache --virtual .fetch-deps \
2122
openssl \
@@ -67,7 +68,7 @@ RUN set -ex \
6768
# add build deps before removing fetch deps in case there's overlap
6869
&& apk del .fetch-deps .cosign \
6970
\
70-
&& for i in /usr/src/*.patch; do \
71+
&& for i in /usr/src/patches/*.patch; do \
7172
patch -d /usr/src/python -p 1 < "${i}"; done \
7273
&& cd /usr/src/python \
7374
&& gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \
@@ -101,8 +102,7 @@ RUN set -ex \
101102
\( \
102103
-type d -a \( -name test -o -name tests \) \
103104
\) -exec rm -rf '{}' + \
104-
&& rm -rf /usr/src/python \
105-
&& rm -f /usr/src/*.patch
105+
&& rm -rf /usr/src/python
106106

107107
# make some useful symlinks that are expected to exist
108108
RUN cd /usr/local/bin \
File renamed without changes.

0 commit comments

Comments
 (0)