Skip to content

feat: add node image variant#143

Closed
Philip Reinken (philipreinken) wants to merge 6 commits into
mainfrom
node-20250828-1452
Closed

feat: add node image variant#143
Philip Reinken (philipreinken) wants to merge 6 commits into
mainfrom
node-20250828-1452

Conversation

@philipreinken

@philipreinken Philip Reinken (philipreinken) commented Aug 29, 2025

Copy link
Copy Markdown
Contributor

Resolves: #138


With this PR, we get another image variant that includes node as well.

Since the use of COPY is a bit unusual, I'll try to explain the direction I took here in more detail.

We need to support:

  • arbitrary node versions, currently v22 and v24 (to support various shopware versions)
  • multiple alpine base image versions (due to varying php versions)
  • musl (due to alpine base image)
  • arm64 processor arch

So just calling apk add nodejs is not an option, as the node versions available to us would be dependant on the alpine repositories referenced in the php:x-fpm-alpine variant we build upon. For example, in php:8.4-fpm-alpine, we can easily get node v22, but not v24.
Even when referencing non-default repos, v24 is not available in edge or any other repo AFAICT, link.

As a first possible solution, there are unofficial builds which work on alpine with its musl libc variant. However, these are available for x86_64 only. Tooling like n or nvm relies on those builds as well, so is of no help here.

Looking at the contents of an exemplary pre-built binary package:

Release contents
node-v22.9.0-linux-x64-musl
├── bin
│   ├── corepack -> ../lib/node_modules/corepack/dist/corepack.js
│   ├── node
│   ├── npm -> ../lib/node_modules/npm/bin/npm-cli.js
│   └── npx -> ../lib/node_modules/npm/bin/npx-cli.js
├── CHANGELOG.md
├── include
│   └── node
├── lib
│   └── node_modules
├── LICENSE
├── README.md
└── share
    ├── doc
    └── man

9 directories, 7 files

...the same binaries/library files are present in the official nodejs-alpine container image, which is also available in all required processor architectures.

Compiling node is another alternative I'm currently looking into, but considering the process required, I believe a few COPY instructions might be easier to maintain.

That said, I'd be happy to hear more ideas on this.

TODO:

  • Shrink down the number of combinations (we likely don't need the newest node version for images with PHP < v8.3)
  • Decide on node build/install process (-> we'll compile)
  • Implement changes for frankenphp image as well

@philipreinken

Copy link
Copy Markdown
Contributor Author

There's a nodejs-current package available in alpine, wich provides v24, making the whole compilation and/or COPY workarounds superfluous. Closing this in favor of #144 .

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.

Add a Docker Variant with Node 22 or Node 24

1 participant