- Notifications
You must be signed in to change notification settings - Fork 2k
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
nschonni commented Sep 19, 2020
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)? |
bb64594 to cc88bcfComparettshivers commented Sep 19, 2020
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 commented Sep 19, 2020
If you run the script with |
cc88bcf to 3672a0bComparettshivers commented Sep 19, 2020
Redid it with the |
PeterDaveHello commented Sep 21, 2020
cc @tianon |
SimenB commented Sep 21, 2020
This shouldn't impact final image as we remove python after building node, no? |
nschonni commented Sep 21, 2020
@SimenB I think you're right, it mostly has an impact on the Alpine builds that the official images make on other architectures |
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 commented Sep 22, 2020
@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 commented Sep 22, 2020 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
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 commented Sep 22, 2020
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 commented Sep 22, 2020
Yes, that would be awesome!
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 commented Sep 22, 2020 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
That sounds even more reasonable. I'll work on modifying |
Dockerfile-alpine.template Outdated
| linux-headers \ | ||
| make \ | ||
| python \ | ||
| python3 \ |
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.
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
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" |
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.
Ah yes that is a better way that how I initially did it. Let me do it that way.
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.
How is it looking now?
6586bc1 to 171439dCompareUh oh!
There was an error while loading. Please reload this page.
171439d to 550d1b4CompareIn 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" |
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.
We could probably keep this as the old "python" and it would minimize the diff
ttshiversSep 22, 2020 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
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.
I'll have to add some additional logic since "python" isn't available on alpine3.12, and there there is 12/alpine3.12
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.
OK, fair enough, was just looking to see what the minimal change would be. If this is it, that should be good
ttshiversSep 22, 2020 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
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.
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 ];thenif(( $(echo "${alpine_version}<3.12" | bc -l) ));then pythonVersion="python"else pythonVersion="python2"fielse pythonVersion="python3"fiThere 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.
I think it looks good now, thanks for the patients
550d1b4 to 3d290f8Comparenschonni commented Sep 22, 2020
@tianon @nodejs/docker should we land this before doing the 14.11.0 PR? |
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 |
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 commented Oct 2, 2020
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 commented Oct 2, 2020
Looks like it worked (or the secret has been added) |
nschonni commented Oct 2, 2020
@ttshivers no, this is still the old PR flow |
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