Skip to content
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

python 2.7 reaches End of Life in 2 months #13

Closed
seanw2020 opened this issue Oct 28, 2019 · 3 comments
Closed

python 2.7 reaches End of Life in 2 months #13

seanw2020 opened this issue Oct 28, 2019 · 3 comments

Comments

@seanw2020
Copy link

seanw2020 commented Oct 28, 2019

First, thank you for this image! Second, could you update it, or create a new tag, for a python3 variant? For example, when I build your Dockerfile here, I see this output:

DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop su
pport for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support

I managed to get python 3 installed in Alpine 3.10 by following this Dockerfile, but adding your suggested mitogen, ansible-lint, and pywinrm packages:

    pip3 install --no-cache mitogen ansible-lint ; \
    pip3 install --no-cache --upgrade pywinrm ; \

Final working version:

FROM alpine:latest

# LABEL maintainer="Johannes Denninger"
# Details: https://github.com/joxz/alpine-ansible-py3/blob/master/Dockerfile
# This is mostly Johannes' work, but with Will Hall's 2 modifcations and bash, git, jq and delete __pycache__, .pyc
# and no entrypoint.sh or su-exec. See https://github.com/cytopia/docker-ansible/blob/master/Dockerfile-tools

RUN set -euxo pipefail ;\
    sed -i 's/http\:\/\/dl-cdn.alpinelinux.org/https\:\/\/alpine.global.ssl.fastly.net/g' /etc/apk/repositories ;\
    apk add --no-cache --update python3 ca-certificates openssh-client sshpass dumb-init bash git jq ;\
    apk add --no-cache --update --virtual .build-deps python3-dev build-base libffi-dev openssl-dev ;\

    pip3 install --no-cache --upgrade pip ;\
    pip3 install --no-cache --upgrade setuptools ansible ;\
    pip3 install --no-cache mitogen ansible-lint ; \
    pip3 install --no-cache --upgrade pywinrm ; \
    apk del --no-cache --purge .build-deps ;\
    rm -rf /var/cache/apk/* ;\
    rm -rf /root/.cache ;\
    ln -s /usr/bin/python3 /usr/bin/python ;\
    mkdir -p /etc/ansible/ ;\
    /bin/echo -e "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts ;\
    ssh-keygen -q -t ed25519 -N '' -f /root/.ssh/id_ed25519 ;\
    mkdir -p ~/.ssh && echo "Host *" > ~/.ssh/config && echo " StrictHostKeyChecking no" >> ~/.ssh/config ;\
    adduser -s /bin/ash -u 1000 -D -h /ansible ansible

COPY ./entrypoint.sh /usr/local/bin
RUN chmod +x /usr/local/bin/entrypoint.sh

# Details: https://stackoverflow.com/a/41386937/1231693
RUN find . -regex '^.*\(__pycache__\|\.py[co]\)$' -delete

ENTRYPOINT ["/usr/bin/dumb-init","--"]

USER ansible
WORKDIR /ansible

Results:

$ docker exec -ti app_ansible_1 python --version
Python 3.7.5

And:
image

@willhallonline
Copy link
Owner

So this all works? Do you want to submit a PR to the Alpine 3.10? Or would you like me to do it?

Secondly, what would you prefer? To run a separate Python 3 version, or to just say "Python 2 is deprecated, use Python 3". What is your preference?

@willhallonline
Copy link
Owner

So, I bounced this issue onto LinkedIn too (https://www.linkedin.com/posts/willhallonline_python-27-reaches-end-of-life-in-2-months-activity-6597158416609796096-9wbS) and it appears that people are in favour of deprecation of Python2 and replacing with Python3.

I will look for how best to easily do this. @seanw2020 Thanks again for bringing it to my attention. 👍 🥇

@Jean-Baptiste-Lasselle
Copy link

Jean-Baptiste-Lasselle commented Mar 5, 2020

idea : integrating https://github.com/pyenv/pyenv in docker builds, to manage python installation ?

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

No branches or pull requests

3 participants