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

nodejs: include npm #56

Merged
merged 2 commits into from
Oct 28, 2022
Merged

nodejs: include npm #56

merged 2 commits into from
Oct 28, 2022

Conversation

imjasonh
Copy link
Contributor

This installs npm when nodejs is installed. https://nodejs.org/en/download/releases/ says nodejs 18.11 includes npm 8.19.2.

This differs from Alpine's approach, whose node package doesn't include npm, and instead it's provided by a separate package in the community repo, which installs npm 9.0.0.

I can have a separate npm package as well if we'd like, and just require folks to install them both together.

Signed-off-by: Jason Hall jason@chainguard.dev

Signed-off-by: Jason Hall <jason@chainguard.dev>
@imjasonh imjasonh requested a review from kaniini October 28, 2022 13:55
Signed-off-by: Jason Hall <jason@chainguard.dev>
@imjasonh
Copy link
Contributor Author

Some more context about Alpine's decision to use a separate package, from when they split it out last year: https://git.alpinelinux.org/aports/commit/main/nodejs/APKBUILD?id=25b10bd1a93e12a7e49fee38b0a229281ae49fb7

I don't have a strong opinion, and we can change to separate packages later if we decide we'd like to.

@luhring
Copy link
Contributor

luhring commented Oct 28, 2022

@imjasonh Could you elaborate on the motivation for this? Is this for convenience for developers using the package?

At first glance I kind of lean toward the separated/minimalist approach, for the reasons mentioned in the Alpine notes. Also thinking about non-dev environments where there's no need for npm.

@imjasonh
Copy link
Contributor Author

That's reasonable. I'd also like to enable a minimal base image capable of running node apps, with none of the stuff needed to build them.

I couldn't find a good example of doing that though -- both the official Node and Docker tutorials for containerizing node apps recommend basing them on their node image, which includes npm. 😕

That's not to say we shouldn't do better, we should. Not being a JS expert myself I just didn't want to do a more complicated thing without a bit more assurance I wasn't making things worse.

To get that assurance I'd want to find/build a runnable example using a multi-stage build and separate dev-time and run-time images, but that will take time. Having a usable node+npm image at all seems like a good first step, and we can build on it to separate out npm when it's all a bit more mature.

@luhring
Copy link
Contributor

luhring commented Oct 28, 2022

That sounds reasonable to me!

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.

None yet

3 participants