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

feat: replace deb.nodesource.com with n, fixes #5509 #5521

Merged
merged 4 commits into from Nov 19, 2023

Conversation

hanoii
Copy link
Collaborator

@hanoii hanoii commented Nov 9, 2023

I figured this one was quick to do if you want to give it a try.

@hanoii hanoii requested a review from a team as a code owner November 9, 2023 12:22
Copy link

github-actions bot commented Nov 9, 2023

@rfay rfay marked this pull request as draft November 9, 2023 18:19
Copy link
Member

@rfay rfay left a comment

Choose a reason for hiding this comment

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

Requires installation in the Dockerfile right?

@hanoii
Copy link
Collaborator Author

hanoii commented Nov 9, 2023

Requires installation in the Dockerfile right?

what do you mean? It modifies the Dockerfile yes, but not the main ddev image, just the one for each project. It modifies as before when you specify a version.

@rfay
Copy link
Member

rfay commented Nov 9, 2023

I think the initial nodejs installation should be done via n probably?

RUN curl -sSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /usr/share/keyrings/nodesource.gpg && \
echo "deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_VERSION.x nodistro main" > /etc/apt/sources.list.d/nodesource.list

@hanoii
Copy link
Collaborator Author

hanoii commented Nov 9, 2023

The recommended way is actually installing it through npm, so it assumes node is already in the system, while this sound as cat and mouse, I find it very useful, since It works much easier than nvm and i can use it on platform.sh for instance to change version.

I thought the node version was on the original image coming form debian, not that you were setting a default initial version yourself.

So we can do either, continue installing the default node version the way you are doing and use n only for changing it, or, as per https://github.com/tj/n#installation you can do:

curl -fsSL https://raw.githubusercontent.com/tj/n/master/bin/n | bash -s 18

18 or whatever you want.

From https://docs.platform.sh/languages/nodejs/node-version.html, if you compare the installation for n vs nvm, you see it's much more straightforward.

Copy link
Member

@rfay rfay left a comment

Choose a reason for hiding this comment

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

This seems like it's close, but the docs have to be updated explaining the range of versions allowed, and the template.go comment instructions need statement that minor versions are supported right?

What about adding info about "Why do we need nvm at all then"? (Do we?)

@@ -41,7 +40,8 @@ func TestNodeJSVersions(t *testing.T) {
err = app.Start()
require.NoError(t, err)

for _, v := range nodeps.GetValidNodeVersions() {
// Testing some random versions
for _, v := range []string{"6", "10", "14", "16", "20"} {
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this have some examples with minor versions?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure

@hanoii
Copy link
Collaborator Author

hanoii commented Nov 16, 2023

What about adding info about "Why do we need nvm at all then"? (Do we?)

This an interesting question. I don't think we do, but some people are used to it, so removing it altogether is a bit step, I guess that if you removed phpmyadmin you can do that with this and move it to an add on, which might not be a bad idea but I'd do that as a separate issue/PR.

I'll add some more info to template.go, I did change that to account for any "node version" but I can try thinking of something more specific.

@hanoii
Copy link
Collaborator Author

hanoii commented Nov 16, 2023

Further more, using n once you start the project is not possible (this can be improved with permissions):

n install 18
  installing : node-v18.18.2
       mkdir : /usr/local/n/versions/node/18.18.2
mkdir: cannot create directory ‘/usr/local/n/versions/node/18.18.2’: Permission denied

  Error: sudo required (or change ownership, or define N_PREFIX)

Obviously N_PREFIX can point to something else, even the shared mnt, but again, if people are used to nvm I thought easier to just leave n as a system node installer and nvm as a user runtime node installer. I wonder how much nvm is used, maybe you have that information out of your analytics?

@hanoii hanoii requested a review from rfay November 16, 2023 12:29
@hanoii
Copy link
Collaborator Author

hanoii commented Nov 16, 2023

Updated docs and tests

@rfay rfay marked this pull request as ready for review November 17, 2023 16:23
@rfay rfay requested a review from a team as a code owner November 17, 2023 16:23
@rfay rfay requested a review from stasadev November 17, 2023 16:25
Copy link
Member

@stasadev stasadev left a comment

Choose a reason for hiding this comment

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

Impressive simplification!

It also "fixes" the problem described here:

@rfay
Copy link
Member

rfay commented Nov 18, 2023

Rebased.

@rfay rfay added this to the v1.22.5 milestone Nov 18, 2023
Copy link
Member

@rfay rfay left a comment

Choose a reason for hiding this comment

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

Rebased and added minor docs changes. I think this is pretty fantastic. It will resolve the conflict people always feel between major version and nvm.

@rfay rfay merged commit c1d9bc6 into ddev:master Nov 19, 2023
17 checks passed
@mandrasch
Copy link
Collaborator

Awesome change, thanks so much @hanoii! 👏 👏 👏

@rfay
Copy link
Member

rfay commented Jan 26, 2024

I'm quite a fan of this as well. Simply fantastic.

@tyler36
Copy link
Collaborator

tyler36 commented Jan 28, 2024

Brilliant!

@rfay
Copy link
Member

rfay commented Feb 3, 2024

A followup on this:

  • nodejs inside the container is still the one in /usr/bin
  • node is in /usr/local/bin/node
  • Docs refer to nodejs a few places
  • We could easily update to add a link /usr/local/bin/nodejs -> /usr/local/bin/node to solve this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants