Skip to content

Commit d9536f1

Browse files
committed
Adjust implementation for smaller diff from existing (keeping "ca-certificates" installed and removing "libressl" after downloading)
1 parent 93c1436 commit d9536f1

File tree

15 files changed

+62
-43
lines changed

15 files changed

+62
-43
lines changed

2.7/alpine3.6/Dockerfile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@ ENV LANG C.UTF-8
1515
# https://github.com/docker-library/python/issues/147
1616
ENV PYTHONIOENCODING UTF-8
1717

18-
# install libressl so that HTTPS works on Alpine <3.7
19-
RUN apk add --no-cache libressl
18+
# install ca-certificates so that HTTPS works consistently (other runtime dependencies for Python are installed later); only needed on Alpine 3.6 (3.7+ includes these in the base)
19+
RUN apk add --no-cache ca-certificates
2020

2121
ENV GPG_KEY C01E1CAD5EA2C4F0B8E3571504C367C218ADD4FF
2222
ENV PYTHON_VERSION 2.7.15
2323

2424
RUN set -ex \
2525
&& apk add --no-cache --virtual .fetch-deps \
2626
gnupg \
27+
libressl \
2728
tar \
2829
xz \
2930
\
@@ -46,6 +47,7 @@ RUN set -ex \
4647
gcc \
4748
gdbm-dev \
4849
libc-dev \
50+
libressl \
4951
libressl-dev \
5052
linux-headers \
5153
make \
@@ -93,9 +95,13 @@ RUN set -ex \
9395
ENV PYTHON_PIP_VERSION 18.0
9496

9597
RUN set -ex; \
98+
\
99+
apk add --no-cache --virtual .fetch-deps libressl; \
96100
\
97101
wget -O get-pip.py 'https://bootstrap.pypa.io/get-pip.py'; \
98102
\
103+
apk del .fetch-deps; \
104+
\
99105
python get-pip.py \
100106
--disable-pip-version-check \
101107
--no-cache-dir \

2.7/alpine3.7/Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ ENV LANG C.UTF-8
1515
# https://github.com/docker-library/python/issues/147
1616
ENV PYTHONIOENCODING UTF-8
1717

18-
# install libressl so that HTTPS works on Alpine <3.7
19-
# RUN apk add --no-cache libressl
20-
2118
ENV GPG_KEY C01E1CAD5EA2C4F0B8E3571504C367C218ADD4FF
2219
ENV PYTHON_VERSION 2.7.15
2320

@@ -98,6 +95,8 @@ RUN set -ex; \
9895
\
9996
wget -O get-pip.py 'https://bootstrap.pypa.io/get-pip.py'; \
10097
\
98+
apk del .fetch-deps; \
99+
\
101100
python get-pip.py \
102101
--disable-pip-version-check \
103102
--no-cache-dir \

2.7/alpine3.8/Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ ENV LANG C.UTF-8
1515
# https://github.com/docker-library/python/issues/147
1616
ENV PYTHONIOENCODING UTF-8
1717

18-
# install libressl so that HTTPS works on Alpine <3.7
19-
# RUN apk add --no-cache libressl
20-
2118
ENV GPG_KEY C01E1CAD5EA2C4F0B8E3571504C367C218ADD4FF
2219
ENV PYTHON_VERSION 2.7.15
2320

@@ -98,6 +95,8 @@ RUN set -ex; \
9895
\
9996
wget -O get-pip.py 'https://bootstrap.pypa.io/get-pip.py'; \
10097
\
98+
apk del .fetch-deps; \
99+
\
101100
python get-pip.py \
102101
--disable-pip-version-check \
103102
--no-cache-dir \

3.4/alpine3.7/Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ ENV PATH /usr/local/bin:$PATH
1313
# > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK.
1414
ENV LANG C.UTF-8
1515

16-
# install libressl so that HTTPS works on Alpine <3.7
17-
# RUN apk add --no-cache libressl
18-
1916
ENV GPG_KEY 97FC712E4C024BBEA48A61ED3A5CA953F73C700D
2017
ENV PYTHON_VERSION 3.4.8
2118

@@ -107,6 +104,8 @@ RUN set -ex; \
107104
\
108105
wget -O get-pip.py 'https://bootstrap.pypa.io/get-pip.py'; \
109106
\
107+
apk del .fetch-deps; \
108+
\
110109
python get-pip.py \
111110
--disable-pip-version-check \
112111
--no-cache-dir \

3.4/alpine3.8/Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ ENV PATH /usr/local/bin:$PATH
1313
# > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK.
1414
ENV LANG C.UTF-8
1515

16-
# install libressl so that HTTPS works on Alpine <3.7
17-
# RUN apk add --no-cache libressl
18-
1916
ENV GPG_KEY 97FC712E4C024BBEA48A61ED3A5CA953F73C700D
2017
ENV PYTHON_VERSION 3.4.8
2118

@@ -107,6 +104,8 @@ RUN set -ex; \
107104
\
108105
wget -O get-pip.py 'https://bootstrap.pypa.io/get-pip.py'; \
109106
\
107+
apk del .fetch-deps; \
108+
\
110109
python get-pip.py \
111110
--disable-pip-version-check \
112111
--no-cache-dir \

3.5/alpine3.7/Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ ENV PATH /usr/local/bin:$PATH
1313
# > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK.
1414
ENV LANG C.UTF-8
1515

16-
# install libressl so that HTTPS works on Alpine <3.7
17-
# RUN apk add --no-cache libressl
18-
1916
ENV GPG_KEY 97FC712E4C024BBEA48A61ED3A5CA953F73C700D
2017
ENV PYTHON_VERSION 3.5.5
2118

@@ -107,6 +104,8 @@ RUN set -ex; \
107104
\
108105
wget -O get-pip.py 'https://bootstrap.pypa.io/get-pip.py'; \
109106
\
107+
apk del .fetch-deps; \
108+
\
110109
python get-pip.py \
111110
--disable-pip-version-check \
112111
--no-cache-dir \

3.5/alpine3.8/Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ ENV PATH /usr/local/bin:$PATH
1313
# > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK.
1414
ENV LANG C.UTF-8
1515

16-
# install libressl so that HTTPS works on Alpine <3.7
17-
# RUN apk add --no-cache libressl
18-
1916
ENV GPG_KEY 97FC712E4C024BBEA48A61ED3A5CA953F73C700D
2017
ENV PYTHON_VERSION 3.5.5
2118

@@ -107,6 +104,8 @@ RUN set -ex; \
107104
\
108105
wget -O get-pip.py 'https://bootstrap.pypa.io/get-pip.py'; \
109106
\
107+
apk del .fetch-deps; \
108+
\
110109
python get-pip.py \
111110
--disable-pip-version-check \
112111
--no-cache-dir \

3.6/alpine3.6/Dockerfile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,16 @@ ENV PATH /usr/local/bin:$PATH
1313
# > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK.
1414
ENV LANG C.UTF-8
1515

16-
# install libressl so that HTTPS works on Alpine <3.7
17-
RUN apk add --no-cache libressl
16+
# install ca-certificates so that HTTPS works consistently (other runtime dependencies for Python are installed later); only needed on Alpine 3.6 (3.7+ includes these in the base)
17+
RUN apk add --no-cache ca-certificates
1818

1919
ENV GPG_KEY 0D96DF4D4110E5C43FBFB17F2D347EA6AA65421D
2020
ENV PYTHON_VERSION 3.6.6
2121

2222
RUN set -ex \
2323
&& apk add --no-cache --virtual .fetch-deps \
2424
gnupg \
25+
libressl \
2526
tar \
2627
xz \
2728
\
@@ -46,6 +47,7 @@ RUN set -ex \
4647
gdbm-dev \
4748
libc-dev \
4849
libffi-dev \
50+
libressl \
4951
libressl-dev \
5052
linux-headers \
5153
make \
@@ -104,9 +106,13 @@ RUN cd /usr/local/bin \
104106
ENV PYTHON_PIP_VERSION 18.0
105107

106108
RUN set -ex; \
109+
\
110+
apk add --no-cache --virtual .fetch-deps libressl; \
107111
\
108112
wget -O get-pip.py 'https://bootstrap.pypa.io/get-pip.py'; \
109113
\
114+
apk del .fetch-deps; \
115+
\
110116
python get-pip.py \
111117
--disable-pip-version-check \
112118
--no-cache-dir \

3.6/alpine3.7/Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ ENV PATH /usr/local/bin:$PATH
1313
# > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK.
1414
ENV LANG C.UTF-8
1515

16-
# install libressl so that HTTPS works on Alpine <3.7
17-
# RUN apk add --no-cache libressl
18-
1916
ENV GPG_KEY 0D96DF4D4110E5C43FBFB17F2D347EA6AA65421D
2017
ENV PYTHON_VERSION 3.6.6
2118

@@ -109,6 +106,8 @@ RUN set -ex; \
109106
\
110107
wget -O get-pip.py 'https://bootstrap.pypa.io/get-pip.py'; \
111108
\
109+
apk del .fetch-deps; \
110+
\
112111
python get-pip.py \
113112
--disable-pip-version-check \
114113
--no-cache-dir \

3.6/alpine3.8/Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ ENV PATH /usr/local/bin:$PATH
1313
# > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK.
1414
ENV LANG C.UTF-8
1515

16-
# install libressl so that HTTPS works on Alpine <3.7
17-
# RUN apk add --no-cache libressl
18-
1916
ENV GPG_KEY 0D96DF4D4110E5C43FBFB17F2D347EA6AA65421D
2017
ENV PYTHON_VERSION 3.6.6
2118

@@ -109,6 +106,8 @@ RUN set -ex; \
109106
\
110107
wget -O get-pip.py 'https://bootstrap.pypa.io/get-pip.py'; \
111108
\
109+
apk del .fetch-deps; \
110+
\
112111
python get-pip.py \
113112
--disable-pip-version-check \
114113
--no-cache-dir \

3.7/alpine3.7/Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ ENV PATH /usr/local/bin:$PATH
1313
# > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK.
1414
ENV LANG C.UTF-8
1515

16-
# install libressl so that HTTPS works on Alpine <3.7
17-
# RUN apk add --no-cache libressl
18-
1916
ENV GPG_KEY 0D96DF4D4110E5C43FBFB17F2D347EA6AA65421D
2017
ENV PYTHON_VERSION 3.7.0
2118

@@ -109,6 +106,8 @@ RUN set -ex; \
109106
\
110107
wget -O get-pip.py 'https://bootstrap.pypa.io/get-pip.py'; \
111108
\
109+
apk del .fetch-deps; \
110+
\
112111
python get-pip.py \
113112
--disable-pip-version-check \
114113
--no-cache-dir \

3.7/alpine3.8/Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ ENV PATH /usr/local/bin:$PATH
1313
# > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK.
1414
ENV LANG C.UTF-8
1515

16-
# install libressl so that HTTPS works on Alpine <3.7
17-
# RUN apk add --no-cache libressl
18-
1916
ENV GPG_KEY 0D96DF4D4110E5C43FBFB17F2D347EA6AA65421D
2017
ENV PYTHON_VERSION 3.7.0
2118

@@ -109,6 +106,8 @@ RUN set -ex; \
109106
\
110107
wget -O get-pip.py 'https://bootstrap.pypa.io/get-pip.py'; \
111108
\
109+
apk del .fetch-deps; \
110+
\
112111
python get-pip.py \
113112
--disable-pip-version-check \
114113
--no-cache-dir \

Dockerfile-alpine.template

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@ ENV PATH /usr/local/bin:$PATH
77
# > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK.
88
ENV LANG C.UTF-8
99

10-
# install libressl so that HTTPS works on Alpine <3.7
11-
# RUN apk add --no-cache libressl
10+
# install ca-certificates so that HTTPS works consistently (other runtime dependencies for Python are installed later); only needed on Alpine 3.6 (3.7+ includes these in the base)
11+
RUN apk add --no-cache ca-certificates
1212

1313
ENV GPG_KEY %%PLACEHOLDER%%
1414
ENV PYTHON_VERSION %%PLACEHOLDER%%
1515

1616
RUN set -ex \
1717
&& apk add --no-cache --virtual .fetch-deps \
1818
gnupg \
19+
libressl \
1920
tar \
2021
xz \
2122
\
@@ -41,6 +42,7 @@ RUN set -ex \
4142
libc-dev \
4243
libffi-dev \
4344
libnsl-dev \
45+
libressl \
4446
libressl-dev \
4547
libtirpc-dev \
4648
linux-headers \
@@ -100,9 +102,13 @@ RUN cd /usr/local/bin \
100102
ENV PYTHON_PIP_VERSION %%PLACEHOLDER%%
101103

102104
RUN set -ex; \
105+
\
106+
apk add --no-cache --virtual .fetch-deps libressl; \
103107
\
104108
wget -O get-pip.py 'https://bootstrap.pypa.io/get-pip.py'; \
105109
\
110+
apk del .fetch-deps; \
111+
\
106112
python get-pip.py \
107113
--disable-pip-version-check \
108114
--no-cache-dir \

Dockerfile-caveman-alpine.template

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,16 @@ ENV LANG C.UTF-8
99
# https://github.com/docker-library/python/issues/147
1010
ENV PYTHONIOENCODING UTF-8
1111

12-
# install libressl so that HTTPS works on Alpine <3.7
13-
# RUN apk add --no-cache libressl
12+
# install ca-certificates so that HTTPS works consistently (other runtime dependencies for Python are installed later); only needed on Alpine 3.6 (3.7+ includes these in the base)
13+
RUN apk add --no-cache ca-certificates
1414

1515
ENV GPG_KEY %%PLACEHOLDER%%
1616
ENV PYTHON_VERSION %%PLACEHOLDER%%
1717

1818
RUN set -ex \
1919
&& apk add --no-cache --virtual .fetch-deps \
2020
gnupg \
21+
libressl \
2122
tar \
2223
xz \
2324
\
@@ -41,6 +42,7 @@ RUN set -ex \
4142
gdbm-dev \
4243
libc-dev \
4344
libnsl-dev \
45+
libressl \
4446
libressl-dev \
4547
libtirpc-dev \
4648
linux-headers \
@@ -89,9 +91,13 @@ RUN set -ex \
8991
ENV PYTHON_PIP_VERSION %%PLACEHOLDER%%
9092

9193
RUN set -ex; \
94+
\
95+
apk add --no-cache --virtual .fetch-deps libressl; \
9296
\
9397
wget -O get-pip.py 'https://bootstrap.pypa.io/get-pip.py'; \
9498
\
99+
apk del .fetch-deps; \
100+
\
95101
python get-pip.py \
96102
--disable-pip-version-check \
97103
--no-cache-dir \

update.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,17 @@ for version in "${versions[@]}"; do
152152
wheezy) sed -ri -e 's/dpkg-architecture --query /dpkg-architecture -q/g' "$dir/Dockerfile" ;;
153153
esac
154154

155+
if [[ "$v" == alpine* ]] && [ "$v" != 'alpine3.6' ]; then
156+
# https://github.com/docker-library/python/pull/307
157+
# on Alpine 3.6 it's necessary to install libressl to get working HTTPS with wget (and ca-certificates for Python's runtime), but later versions don't require this (support for both is baked into the base)
158+
sed -ri -e '/(libressl|openssl|ca-certificates)([ ;]|$)/d' "$dir/Dockerfile"
159+
160+
# remove any double-empty (or double-empty-continuation) lines the above created
161+
uniq "$dir/Dockerfile" > "$dir/Dockerfile.new"
162+
mv "$dir/Dockerfile.new" "$dir/Dockerfile"
163+
fi
164+
155165
case "$version/$v" in
156-
# On Alpine 3.6 it's necessary to install libressl to get working HTTPS.
157-
# Later Alpine versions have CA certificates pre-installed.
158-
*/alpine3.6)
159-
sed -ri -e '/^# .* libressl$/s/^# //' "$dir/Dockerfile"
160-
;;& # (other patches needed for Alpine 3.6 in later blocks)
161166
# https://bugs.python.org/issue32598 (Python 3.7.0b1+)
162167
# TL;DR: Python 3.7+ uses OpenSSL functionality which LibreSSL 2.6.x in Alpine 3.7 doesn't implement
163168
# Python 3.5 on Alpine 3.8 needs OpenSSL too

0 commit comments

Comments
 (0)