Skip to content

fix: use python3 or python2 for alpine #1331

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
Oct 2, 2020

Conversation

ttshivers
Copy link
Member

In alpine3.12, they removed the python package in favor of either python2 or python3.
https://wiki.alpinelinux.org/wiki/Release_Notes_for_Alpine_3.12.0#python2_no_longer_provides_python_and_python-devel

Refs #1330

@nschonni
Copy link
Member

Thanks, these changes will need to be made in https://github.com/nodejs/docker-node/blob/master/Dockerfile-alpine.template since these files are generated. Do you know if python 3 would be applicable to all the previous builds as well (3.9-3.12)?

@ttshivers ttshivers force-pushed the alpine3.12-fix branch 2 times, most recently from bb64594 to cc88bcf Compare September 19, 2020 22:49
@ttshivers
Copy link
Member Author

The python3 package is available in alpine 3.9-3.12, so it should be fine to switch the template to use python3. I went ahead and made the change to the template and ran the update script.

@nschonni
Copy link
Member

If you run the script with -s you won't get all the extra changes for the Yarn version

@ttshivers
Copy link
Member Author

Redid it with the -s flag

@nschonni nschonni requested a review from a team September 19, 2020 23:26
@nschonni nschonni changed the title fix: switch python to python3 for alpine3.12 fix: switch python to python3 for alpine Sep 19, 2020
@PeterDaveHello PeterDaveHello requested a review from a team September 21, 2020 14:53
@PeterDaveHello
Copy link
Member

cc @tianon

@SimenB
Copy link
Member

SimenB commented Sep 21, 2020

This shouldn't impact final image as we remove python after building node, no?

@nschonni
Copy link
Member

@SimenB I think you're right, it mostly has an impact on the Alpine builds that the official images make on other architectures

@tianon
Copy link
Contributor

tianon commented Sep 21, 2020

Has this change been tested on an architecture other than amd64 where Node does have to build from source? (where it's currently failing)

@nschonni
Copy link
Member

@ttshivers did you test this out on one of the other platforms? I'm guessing you might be running on one of those since you opened up the other issue

@ttshivers
Copy link
Member Author

ttshivers commented Sep 22, 2020

Let me try and build all the images on the various arches and see how it goes. Perhaps modifying the github actions to use buildx to build on multiple arches might be useful? I could do a PR for this.

@ttshivers
Copy link
Member Author

It appears on nodejs <= 12, python2 is required for building on some architectures. (I ran into an issue building 10/alpine3.10 on linux/arm64)

One solution is to install both python2 and python3. Another is to install just python2.

@SimenB
Copy link
Member

SimenB commented Sep 22, 2020

Perhaps modifying the github actions to use buildx to build on multiple arches might be useful? I could do a PR for this.

Yes, that would be awesome!

One solution is to install both python2 and python3. Another is to install just python2.

Seeing as python2 is EOL, I think we should install v3 for those builds that supports it, but keep 2 for the ones that don't?

@ttshivers
Copy link
Member Author

ttshivers commented Sep 22, 2020

Seeing as python2 is EOL, I think we should install v3 for those builds that supports it, but keep 2 for the ones that don't?

That sounds even more reasonable. I'll work on modifying update.sh to generate the Dockerfiles with the appropriate python version.

@@ -33,7 +33,7 @@ RUN addgroup -g 1000 node \
libgcc \
linux-headers \
make \
python \
python3 \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe ${PYTHON_VERSION} and do the replacement in the update. (Just kind of repeating what you said you were working on :))
You could fuzzy match in here for the replacement

docker-node/update.sh

Lines 163 to 169 in 3a5c226

if is_alpine "${variant}"; then
alpine_version="${variant#*alpine}"
checksum="\"$(
curl -sSL --compressed "https://unofficial-builds.nodejs.org/download/release/v${nodeVersion}/SHASUMS256.txt" | grep "node-v${nodeVersion}-linux-x64-musl.tar.xz" | cut -d' ' -f1
)\""
sed -Ei -e "s/(alpine:)0.0/\\1${alpine_version}/" "${dockerfile}-tmp"
sed -Ei -e "s/CHECKSUM=CHECKSUM_x64/CHECKSUM=${checksum}/" "${dockerfile}-tmp"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes that is a better way that how I initially did it. Let me do it that way.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is it looking now?

@ttshivers ttshivers force-pushed the alpine3.12-fix branch 3 times, most recently from 6586bc1 to 171439d Compare September 22, 2020 23:36
In alpine3.12, they removed the python package in favor of either
python2 or python3.
https://wiki.alpinelinux.org/wiki/Release_Notes_for_Alpine_3.12.0#python2_no_longer_provides_python_and_python-devel

However, nodejs 12, 10 require python2 for building from source. I added
a change in update.sh that swaps out python3 for python2 in those older
versions for alpine Dockerfiles.

Refs nodejs#1330

# Replace python3 with python2 for nodejs < 14 on alpine
if [ "$version" -lt 14 ]; then
pythonVersion="python2"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could probably keep this as the old "python" and it would minimize the diff

Copy link
Member Author

@ttshivers ttshivers Sep 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll have to add some additional logic since "python" isn't available on alpine3.12, and there there is 12/alpine3.12

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, fair enough, was just looking to see what the minimal change would be. If this is it, that should be good

Copy link
Member Author

@ttshivers ttshivers Sep 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could add a check for alpine < 3.12 and nodejs < 14 and have it use "python" in that case. Would that be preferred?
Ex:

      if [ "$version" -lt 14 ]; then
        if (( $(echo "${alpine_version} < 3.12" | bc -l) )); then
          pythonVersion="python"
        else
          pythonVersion="python2"
        fi
      else
        pythonVersion="python3"
      fi

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it looks good now, thanks for the patients

@ttshivers ttshivers changed the title fix: switch python to python3 for alpine fix: use python3 or python2 for alpine Sep 22, 2020
@nschonni
Copy link
Member

@tianon @nodejs/docker should we land this before doing the 14.11.0 PR?

@tianon
Copy link
Contributor

tianon commented Sep 23, 2020

LGTM, but #1312 (comment) should be resolved first (or the PR bot disabled) to ensure the downstream PR is good

I tested this on arm64 with docker build --pull https://github.com/nodejs/docker-node.git#refs/pull/1331/merge:10/alpine3.11 and docker build --pull https://github.com/nodejs/docker-node.git#refs/pull/1331/merge:14/alpine3.12 successfully (didn't test all versions, but that's enough to satisfy me that this is definitely better than where we're at now 😄).

@nschonni
Copy link
Member

nschonni commented Oct 2, 2020

@tianon we're a little stalled pinging the admin folks to get the secret set on this repo to fix the PR. I'm going to land this one and the 4.12 while we work it out. Hopefully after you get a change to deploy those, we can get the new setup for the pending 4.13 release PR

@nodejs-github-bot
Copy link
Collaborator

Created PR to the official-images repo (docker-library/official-images#8820). See https://github.com/docker-library/faq#an-images-source-changed-in-git-now-what if you are wondering when it will be available on the Docker Hub.

@ttshivers
Copy link
Member Author

Looks like it worked (or the secret has been added)

@nschonni
Copy link
Member

nschonni commented Oct 2, 2020

@ttshivers no, this is still the old PR flow

@ttshivers ttshivers deleted the alpine3.12-fix branch October 13, 2020 19:00
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.

6 participants