Skip to content

Commit 86e133d

Browse files
authored
Merge pull request #310 from infosiftr/dpkg-dev
Fix accidental dpkg-dev purging on non-slim variants
2 parents 10d5ea2 + eaeaf30 commit 86e133d

File tree

21 files changed

+225
-121
lines changed

21 files changed

+225
-121
lines changed

2.7/jessie/Dockerfile

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,11 @@ ENV GPG_KEY C01E1CAD5EA2C4F0B8E3571504C367C218ADD4FF
1919
ENV PYTHON_VERSION 2.7.15
2020

2121
RUN set -ex \
22-
&& buildDeps=' \
23-
dpkg-dev \
22+
&& savedAptMark="$(apt-mark showmanual)" \
23+
&& apt-get update && apt-get install -y --no-install-recommends \
2424
tcl-dev \
2525
tk-dev \
26-
' \
27-
&& apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \
26+
&& rm -rf /var/lib/apt/lists/* \
2827
\
2928
&& wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" \
3029
&& wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc" \
@@ -46,15 +45,19 @@ RUN set -ex \
4645
&& make install \
4746
&& ldconfig \
4847
\
49-
&& apt-get purge -y --auto-remove $buildDeps \
48+
&& apt-mark auto '.*' > /dev/null \
49+
&& apt-mark manual $savedAptMark \
50+
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
5051
\
5152
&& find /usr/local -depth \
5253
\( \
5354
\( -type d -a \( -name test -o -name tests \) \) \
5455
-o \
5556
\( -type f -a \( -name '*.pyc' -o -name '*.pyo' \) \) \
5657
\) -exec rm -rf '{}' + \
57-
&& rm -rf /usr/src/python
58+
&& rm -rf /usr/src/python \
59+
\
60+
&& python2 --version
5861

5962
# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
6063
ENV PYTHON_PIP_VERSION 10.0.1

2.7/jessie/slim/Dockerfile

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ ENV GPG_KEY C01E1CAD5EA2C4F0B8E3571504C367C218ADD4FF
2323
ENV PYTHON_VERSION 2.7.15
2424

2525
RUN set -ex \
26-
&& buildDeps=" \
26+
&& savedAptMark="$(apt-mark showmanual)" \
27+
&& apt-get update && apt-get install -y --no-install-recommends \
2728
dpkg-dev \
2829
gcc \
2930
libbz2-dev \
@@ -42,8 +43,7 @@ RUN set -ex \
4243
zlib1g-dev \
4344
# as of Stretch, "gpg" is no longer included by default
4445
$(command -v gpg > /dev/null || echo 'gnupg dirmngr') \
45-
" \
46-
&& apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \
46+
&& rm -rf /var/lib/apt/lists/* \
4747
\
4848
&& wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" \
4949
&& wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc" \
@@ -65,28 +65,35 @@ RUN set -ex \
6565
&& make install \
6666
&& ldconfig \
6767
\
68-
&& apt-get purge -y --auto-remove $buildDeps \
68+
&& apt-mark auto '.*' > /dev/null \
69+
&& apt-mark manual $savedAptMark \
70+
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
6971
\
7072
&& find /usr/local -depth \
7173
\( \
7274
\( -type d -a \( -name test -o -name tests \) \) \
7375
-o \
7476
\( -type f -a \( -name '*.pyc' -o -name '*.pyo' \) \) \
7577
\) -exec rm -rf '{}' + \
76-
&& rm -rf /usr/src/python
78+
&& rm -rf /usr/src/python \
79+
\
80+
&& python2 --version
7781

7882
# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
7983
ENV PYTHON_PIP_VERSION 10.0.1
8084

8185
RUN set -ex; \
8286
\
87+
savedAptMark="$(apt-mark showmanual)"; \
8388
apt-get update; \
8489
apt-get install -y --no-install-recommends wget; \
8590
rm -rf /var/lib/apt/lists/*; \
8691
\
8792
wget -O get-pip.py 'https://bootstrap.pypa.io/get-pip.py'; \
8893
\
89-
apt-get purge -y --auto-remove wget; \
94+
apt-mark auto '.*' > /dev/null; \
95+
[ -z "$savedAptMark" ] || apt-mark manual $savedAptMark; \
96+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
9097
\
9198
python get-pip.py \
9299
--disable-pip-version-check \

2.7/stretch/Dockerfile

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,11 @@ ENV GPG_KEY C01E1CAD5EA2C4F0B8E3571504C367C218ADD4FF
1919
ENV PYTHON_VERSION 2.7.15
2020

2121
RUN set -ex \
22-
&& buildDeps=' \
23-
dpkg-dev \
22+
&& savedAptMark="$(apt-mark showmanual)" \
23+
&& apt-get update && apt-get install -y --no-install-recommends \
2424
tcl-dev \
2525
tk-dev \
26-
' \
27-
&& apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \
26+
&& rm -rf /var/lib/apt/lists/* \
2827
\
2928
&& wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" \
3029
&& wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc" \
@@ -46,15 +45,19 @@ RUN set -ex \
4645
&& make install \
4746
&& ldconfig \
4847
\
49-
&& apt-get purge -y --auto-remove $buildDeps \
48+
&& apt-mark auto '.*' > /dev/null \
49+
&& apt-mark manual $savedAptMark \
50+
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
5051
\
5152
&& find /usr/local -depth \
5253
\( \
5354
\( -type d -a \( -name test -o -name tests \) \) \
5455
-o \
5556
\( -type f -a \( -name '*.pyc' -o -name '*.pyo' \) \) \
5657
\) -exec rm -rf '{}' + \
57-
&& rm -rf /usr/src/python
58+
&& rm -rf /usr/src/python \
59+
\
60+
&& python2 --version
5861

5962
# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
6063
ENV PYTHON_PIP_VERSION 10.0.1

2.7/stretch/slim/Dockerfile

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ ENV GPG_KEY C01E1CAD5EA2C4F0B8E3571504C367C218ADD4FF
2323
ENV PYTHON_VERSION 2.7.15
2424

2525
RUN set -ex \
26-
&& buildDeps=" \
26+
&& savedAptMark="$(apt-mark showmanual)" \
27+
&& apt-get update && apt-get install -y --no-install-recommends \
2728
dpkg-dev \
2829
gcc \
2930
libbz2-dev \
@@ -42,8 +43,7 @@ RUN set -ex \
4243
zlib1g-dev \
4344
# as of Stretch, "gpg" is no longer included by default
4445
$(command -v gpg > /dev/null || echo 'gnupg dirmngr') \
45-
" \
46-
&& apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \
46+
&& rm -rf /var/lib/apt/lists/* \
4747
\
4848
&& wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" \
4949
&& wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc" \
@@ -65,28 +65,35 @@ RUN set -ex \
6565
&& make install \
6666
&& ldconfig \
6767
\
68-
&& apt-get purge -y --auto-remove $buildDeps \
68+
&& apt-mark auto '.*' > /dev/null \
69+
&& apt-mark manual $savedAptMark \
70+
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
6971
\
7072
&& find /usr/local -depth \
7173
\( \
7274
\( -type d -a \( -name test -o -name tests \) \) \
7375
-o \
7476
\( -type f -a \( -name '*.pyc' -o -name '*.pyo' \) \) \
7577
\) -exec rm -rf '{}' + \
76-
&& rm -rf /usr/src/python
78+
&& rm -rf /usr/src/python \
79+
\
80+
&& python2 --version
7781

7882
# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
7983
ENV PYTHON_PIP_VERSION 10.0.1
8084

8185
RUN set -ex; \
8286
\
87+
savedAptMark="$(apt-mark showmanual)"; \
8388
apt-get update; \
8489
apt-get install -y --no-install-recommends wget; \
8590
rm -rf /var/lib/apt/lists/*; \
8691
\
8792
wget -O get-pip.py 'https://bootstrap.pypa.io/get-pip.py'; \
8893
\
89-
apt-get purge -y --auto-remove wget; \
94+
apt-mark auto '.*' > /dev/null; \
95+
[ -z "$savedAptMark" ] || apt-mark manual $savedAptMark; \
96+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
9097
\
9198
python get-pip.py \
9299
--disable-pip-version-check \

2.7/wheezy/Dockerfile

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,11 @@ ENV GPG_KEY C01E1CAD5EA2C4F0B8E3571504C367C218ADD4FF
1919
ENV PYTHON_VERSION 2.7.15
2020

2121
RUN set -ex \
22-
&& buildDeps=' \
23-
dpkg-dev \
22+
&& savedAptMark="$(apt-mark showmanual)" \
23+
&& apt-get update && apt-get install -y --no-install-recommends \
2424
tcl-dev \
2525
tk-dev \
26-
' \
27-
&& apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \
26+
&& rm -rf /var/lib/apt/lists/* \
2827
\
2928
&& wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" \
3029
&& wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc" \
@@ -46,15 +45,19 @@ RUN set -ex \
4645
&& make install \
4746
&& ldconfig \
4847
\
49-
&& apt-get purge -y --auto-remove $buildDeps \
48+
&& apt-mark auto '.*' > /dev/null \
49+
&& apt-mark manual $savedAptMark \
50+
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
5051
\
5152
&& find /usr/local -depth \
5253
\( \
5354
\( -type d -a \( -name test -o -name tests \) \) \
5455
-o \
5556
\( -type f -a \( -name '*.pyc' -o -name '*.pyo' \) \) \
5657
\) -exec rm -rf '{}' + \
57-
&& rm -rf /usr/src/python
58+
&& rm -rf /usr/src/python \
59+
\
60+
&& python2 --version
5861

5962
# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
6063
ENV PYTHON_PIP_VERSION 10.0.1

3.4/jessie/Dockerfile

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,11 @@ ENV GPG_KEY 97FC712E4C024BBEA48A61ED3A5CA953F73C700D
2323
ENV PYTHON_VERSION 3.4.8
2424

2525
RUN set -ex \
26-
&& buildDeps=' \
27-
dpkg-dev \
26+
&& savedAptMark="$(apt-mark showmanual)" \
27+
&& apt-get update && apt-get install -y --no-install-recommends \
2828
tcl-dev \
2929
tk-dev \
30-
' \
31-
&& apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \
30+
&& rm -rf /var/lib/apt/lists/* \
3231
\
3332
&& wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" \
3433
&& wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc" \
@@ -53,15 +52,19 @@ RUN set -ex \
5352
&& make install \
5453
&& ldconfig \
5554
\
56-
&& apt-get purge -y --auto-remove $buildDeps \
55+
&& apt-mark auto '.*' > /dev/null \
56+
&& apt-mark manual $savedAptMark \
57+
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
5758
\
5859
&& find /usr/local -depth \
5960
\( \
6061
\( -type d -a \( -name test -o -name tests \) \) \
6162
-o \
6263
\( -type f -a \( -name '*.pyc' -o -name '*.pyo' \) \) \
6364
\) -exec rm -rf '{}' + \
64-
&& rm -rf /usr/src/python
65+
&& rm -rf /usr/src/python \
66+
\
67+
&& python3 --version
6568

6669
# make some useful symlinks that are expected to exist
6770
RUN cd /usr/local/bin \

3.4/jessie/slim/Dockerfile

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ ENV GPG_KEY 97FC712E4C024BBEA48A61ED3A5CA953F73C700D
2929
ENV PYTHON_VERSION 3.4.8
3030

3131
RUN set -ex \
32-
&& buildDeps=" \
32+
&& savedAptMark="$(apt-mark showmanual)" \
33+
&& apt-get update && apt-get install -y --no-install-recommends \
3334
dpkg-dev \
3435
gcc \
3536
libbz2-dev \
@@ -50,8 +51,7 @@ RUN set -ex \
5051
zlib1g-dev \
5152
# as of Stretch, "gpg" is no longer included by default
5253
$(command -v gpg > /dev/null || echo 'gnupg dirmngr') \
53-
" \
54-
&& apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \
54+
&& rm -rf /var/lib/apt/lists/* \
5555
\
5656
&& wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" \
5757
&& wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc" \
@@ -76,15 +76,19 @@ RUN set -ex \
7676
&& make install \
7777
&& ldconfig \
7878
\
79-
&& apt-get purge -y --auto-remove $buildDeps \
79+
&& apt-mark auto '.*' > /dev/null \
80+
&& apt-mark manual $savedAptMark \
81+
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
8082
\
8183
&& find /usr/local -depth \
8284
\( \
8385
\( -type d -a \( -name test -o -name tests \) \) \
8486
-o \
8587
\( -type f -a \( -name '*.pyc' -o -name '*.pyo' \) \) \
8688
\) -exec rm -rf '{}' + \
87-
&& rm -rf /usr/src/python
89+
&& rm -rf /usr/src/python \
90+
\
91+
&& python3 --version
8892

8993
# make some useful symlinks that are expected to exist
9094
RUN cd /usr/local/bin \
@@ -98,13 +102,16 @@ ENV PYTHON_PIP_VERSION 10.0.1
98102

99103
RUN set -ex; \
100104
\
105+
savedAptMark="$(apt-mark showmanual)"; \
101106
apt-get update; \
102107
apt-get install -y --no-install-recommends wget; \
103108
rm -rf /var/lib/apt/lists/*; \
104109
\
105110
wget -O get-pip.py 'https://bootstrap.pypa.io/get-pip.py'; \
106111
\
107-
apt-get purge -y --auto-remove wget; \
112+
apt-mark auto '.*' > /dev/null; \
113+
[ -z "$savedAptMark" ] || apt-mark manual $savedAptMark; \
114+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
108115
\
109116
python get-pip.py \
110117
--disable-pip-version-check \

3.4/wheezy/Dockerfile

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,11 @@ ENV GPG_KEY 97FC712E4C024BBEA48A61ED3A5CA953F73C700D
2323
ENV PYTHON_VERSION 3.4.8
2424

2525
RUN set -ex \
26-
&& buildDeps=' \
27-
dpkg-dev \
26+
&& savedAptMark="$(apt-mark showmanual)" \
27+
&& apt-get update && apt-get install -y --no-install-recommends \
2828
tcl-dev \
2929
tk-dev \
30-
' \
31-
&& apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \
30+
&& rm -rf /var/lib/apt/lists/* \
3231
\
3332
&& wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" \
3433
&& wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc" \
@@ -53,15 +52,19 @@ RUN set -ex \
5352
&& make install \
5453
&& ldconfig \
5554
\
56-
&& apt-get purge -y --auto-remove $buildDeps \
55+
&& apt-mark auto '.*' > /dev/null \
56+
&& apt-mark manual $savedAptMark \
57+
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
5758
\
5859
&& find /usr/local -depth \
5960
\( \
6061
\( -type d -a \( -name test -o -name tests \) \) \
6162
-o \
6263
\( -type f -a \( -name '*.pyc' -o -name '*.pyo' \) \) \
6364
\) -exec rm -rf '{}' + \
64-
&& rm -rf /usr/src/python
65+
&& rm -rf /usr/src/python \
66+
\
67+
&& python3 --version
6568

6669
# make some useful symlinks that are expected to exist
6770
RUN cd /usr/local/bin \

0 commit comments

Comments
 (0)