Skip to content

Python 2.7 Alpine variant #80

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 1 commit into from
Jan 12, 2016
Merged

Conversation

soullivaneuh
Copy link
Contributor

Closes #79.

@tianon
Copy link
Member

tianon commented Jan 12, 2016

A couple useful diffs:

$ diff -u 2.7/slim/Dockerfile <(curl -fsSL 'https://raw.githubusercontent.com/Soullivaneuh/python/2.7-alpine/2.7/alpine/Dockerfile')
--- 2.7/slim/Dockerfile 2016-01-11 12:19:23.005163475 -0800
+++ /dev/fd/63  2016-01-12 08:23:00.535696053 -0800
@@ -1,62 +1,57 @@
-FROM debian:jessie
-
-# remove several traces of debian python
-RUN apt-get purge -y python.*
-
-# http://bugs.python.org/issue19846
-# > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK.
-ENV LANG C.UTF-8
-
-RUN apt-get update && apt-get install -y --no-install-recommends \
-       ca-certificates \
-       libsqlite3-0 \
-       libssl1.0.0 \
-   && rm -rf /var/lib/apt/lists/*
+FROM alpine:3.3

 # gpg: key 18ADD4FF: public key "Benjamin Peterson <benjamin@python.org>" imported
-RUN gpg --keyserver ha.pool.sks-keyservers.net --recv-keys C01E1CAD5EA2C4F0B8E3571504C367C218ADD4FF
+ENV GPG_KEY C01E1CAD5EA2C4F0B8E3571504C367C218ADD4FF

 ENV PYTHON_VERSION 2.7.11

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

-RUN set -x \
-   && buildDeps=' \
-       curl \
-       gcc \
-       libbz2-dev \
-       libc6-dev \
-       libncurses-dev \
-       libreadline-dev \
-       libsqlite3-dev \
-       libssl-dev \
-       make \
-       xz-utils \
-       zlib1g-dev \
-   ' \
-   && apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \
-   && mkdir -p /usr/src/python \
+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/Python-$PYTHON_VERSION.tar.xz" -o python.tar.xz \
    && curl -fSL "https://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tar.xz.asc" -o python.tar.xz.asc \
    && gpg --verify python.tar.xz.asc \
-   && tar -xJC /usr/src/python --strip-components=1 -f python.tar.xz \
+   && mkdir -p /usr/src \
+   && tar -xJC /usr/src -f python.tar.xz \
+   && mv "/usr/src/Python-$PYTHON_VERSION" /usr/src/python \
    && rm python.tar.xz* \
+   && rm -r ~/.gnupg \
+   \
+   && apk add --no-cache --virtual .build-deps  \
+       bzip2-dev \
+       gcc \
+       libc-dev \
+       linux-headers \
+       make \
+       ncurses-dev \
+       openssl-dev \
+       pax-utils \
+       readline-dev \
+       sqlite-dev \
+       zlib-dev \
    && cd /usr/src/python \
    && ./configure --enable-shared --enable-unicode=ucs4 \
    && make -j$(nproc) \
    && make install \
-   && ldconfig \
    && curl -fSL 'https://bootstrap.pypa.io/get-pip.py' | python2 \
    && pip install --no-cache-dir --upgrade pip==$PYTHON_PIP_VERSION \
    && find /usr/local \
        \( -type d -a -name test -o -name tests \) \
        -o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \
        -exec rm -rf '{}' + \
-   && apt-get purge -y --auto-remove $buildDeps \
+   && 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 .fetch-deps \
+   && apk del .build-deps \
    && rm -rf /usr/src/python

-# install "virtualenv", since the vast majority of users of this image will want it
-RUN pip install --no-cache-dir virtualenv
-
 CMD ["python2"]
$ diff -u 3.5/alpine/Dockerfile <(curl -fsSL 'https://raw.githubusercontent.com/Soullivaneuh/python/2.7-alpine/2.7/alpine/Dockerfile')
--- 3.5/alpine/Dockerfile   2016-01-11 12:19:24.170132154 -0800
+++ /dev/fd/63  2016-01-12 08:22:23.405829497 -0800
@@ -1,9 +1,9 @@
 FROM alpine:3.3

-# gpg: key F73C700D: public key "Larry Hastings <larry@hastings.org>" imported
-ENV GPG_KEY 97FC712E4C024BBEA48A61ED3A5CA953F73C700D
+# gpg: key 18ADD4FF: public key "Benjamin Peterson <benjamin@python.org>" imported
+ENV GPG_KEY C01E1CAD5EA2C4F0B8E3571504C367C218ADD4FF

-ENV PYTHON_VERSION 3.5.1
+ENV PYTHON_VERSION 2.7.11

 # if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
 ENV PYTHON_PIP_VERSION 7.1.2
@@ -11,14 +11,13 @@
 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 \
+   && curl -fSL "https://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tar.xz" -o python.tar.xz \
+   && curl -fSL "https://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tar.xz.asc" -o python.tar.xz.asc \
    && gpg --verify python.tar.xz.asc \
    && mkdir -p /usr/src \
    && tar -xJC /usr/src -f python.tar.xz \
    && mv "/usr/src/Python-$PYTHON_VERSION" /usr/src/python \
    && rm python.tar.xz* \
-   && apk del .fetch-deps \
    && rm -r ~/.gnupg \
    \
    && apk add --no-cache --virtual .build-deps  \
@@ -35,9 +34,10 @@
        zlib-dev \
    && cd /usr/src/python \
    && ./configure --enable-shared --enable-unicode=ucs4 \
-   && make -j$(getconf _NPROCESSORS_ONLN) \
+   && make -j$(nproc) \
    && make install \
-   && pip3 install --no-cache-dir --upgrade --ignore-installed pip==$PYTHON_PIP_VERSION \
+   && curl -fSL 'https://bootstrap.pypa.io/get-pip.py' | python2 \
+   && pip install --no-cache-dir --upgrade pip==$PYTHON_PIP_VERSION \
    && find /usr/local \
        \( -type d -a -name test -o -name tests \) \
        -o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \
@@ -50,15 +50,8 @@
            | sort -u \
    )" \
    && apk add --virtual .python-rundeps $runDeps \
+   && apk del .fetch-deps \
    && apk del .build-deps \
    && rm -rf /usr/src/python

-# make some useful symlinks that are expected to exist
-RUN cd /usr/local/bin \
-   && ln -s easy_install-3.5 easy_install \
-   && ln -s idle3 idle \
-   && ln -s pydoc3 pydoc \
-   && ln -s python3 python \
-   && ln -s python-config3 python-config
-
-CMD ["python3"]
+CMD ["python2"]

@soullivaneuh
Copy link
Contributor Author

Hmm yes OK, but what should I do? :-)

Is this PR OK for you?

@tianon
Copy link
Member

tianon commented Jan 12, 2016

Yeah, this is fine -- I think @yosifkit is going to merge and then I'll just fold a few minor tweaks into #81. 👍

@soullivaneuh
Copy link
Contributor Author

Glad to hear that! I'm waiting for the merge so. 👍

@yosifkit
Copy link
Member

LGTM

yosifkit added a commit that referenced this pull request Jan 12, 2016
@yosifkit yosifkit merged commit 6ebb4af into docker-library:master Jan 12, 2016
@soullivaneuh soullivaneuh deleted the 2.7-alpine branch January 12, 2016 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy