forked from docker-library/python
-
Notifications
You must be signed in to change notification settings - Fork 0
Adjust whitespace for better symmetry between Dockerfiles and cut image size in half by keeping fetch and compile in the same layer so the Python source goes away properly #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,27 @@ | ||
FROM alpine:3.3 | ||
|
||
# gpg: key F73C700D: public key "Larry Hastings <[email protected]>" imported | ||
ENV GPG_KEY 97FC712E4C024BBEA48A61ED3A5CA953F73C700D | ||
|
||
ENV PYTHON_VERSION 3.5.1 | ||
|
||
# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'" | ||
ENV PYTHON_PIP_VERSION 7.1.2 | ||
|
||
# gpg: key F73C700D: public key "Larry Hastings <[email protected]>" imported | ||
ENV GPG_KEY 97FC712E4C024BBEA48A61ED3A5CA953F73C700D | ||
|
||
RUN apk add --no-cache --virtual .fetch-deps curl gnupg \ | ||
&& gpg --keyserver ha.pool.sks-keyservers.net --recv-keys $GPG_KEY \ | ||
RUN set -ex \ | ||
&& apk add --no-cache --virtual .fetch-deps curl gnupg \ | ||
&& gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$GPG_KEY" \ | ||
&& curl -fSL "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" -o python.tar.xz \ | ||
&& curl -fSL "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc" -o python.tar.xz.asc \ | ||
&& gpg --verify python.tar.xz.asc \ | ||
&& mkdir -p /usr/src/ \ | ||
&& mkdir -p /usr/src \ | ||
&& tar -xJC /usr/src -f python.tar.xz \ | ||
&& mv /usr/src/Python-${PYTHON_VERSION} /usr/src/python \ | ||
&& mv "/usr/src/Python-$PYTHON_VERSION" /usr/src/python \ | ||
&& rm python.tar.xz* \ | ||
&& apk del .fetch-deps | ||
|
||
RUN apk add --no-cache --virtual .build-deps \ | ||
&& apk del .fetch-deps \ | ||
&& rm -r ~/.gnupg \ | ||
\ | ||
&& apk add --no-cache --virtual .build-deps \ | ||
bzip2-dev \ | ||
gcc \ | ||
libc-dev \ | ||
|
@@ -28,9 +30,9 @@ RUN apk add --no-cache --virtual .build-deps \ | |
make \ | ||
ncurses-dev \ | ||
openssl-dev \ | ||
pax-utils \ | ||
sqlite-dev \ | ||
zlib-dev \ | ||
pax-utils \ | ||
&& cd /usr/src/python \ | ||
&& ./configure --enable-shared --enable-unicode=ucs4 \ | ||
&& make -j$(getconf _NPROCESSORS_ONLN) \ | ||
|
@@ -40,12 +42,14 @@ RUN apk add --no-cache --virtual .build-deps \ | |
\( -type d -a -name test -o -name tests \) \ | ||
-o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \ | ||
-exec rm -rf '{}' + \ | ||
&& rundeps=$(scanelf -R -n --nobanner /usr/local/ \ | ||
| awk '{gsub(/,/,"\n",$2); print $2}' \ | ||
| sort -u | sed 's/^/so:/' | while read dep; do \ | ||
apk info --installed -q $dep && echo $dep; \ | ||
done | sort -u) \ | ||
&& apk add --virtual .python-rundeps $rundeps \ | ||
&& runDeps="$( \ | ||
scanelf --needed --nobanner --recursive /usr/local \ | ||
| awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \ | ||
| sort -u \ | ||
| xargs -r apk info --installed \ | ||
| sort -u \ | ||
)" \ | ||
&& apk add --virtual .python-rundeps $runDeps \ | ||
&& apk del .build-deps \ | ||
&& rm -rf /usr/src/python | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this second
sort -u
actually necessary? Ourwhile
loop has just filtered the output of the firstsort
, so this one should be a no-op.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind, figured out something simpler that skips the loop. 😄