Docker strapi node:18.16-alpine sharp (node-gyp) problem (SOLVED)

There is a problem with current dockerfiles Docker | Strapi Documentation.

Dockerfiles are pointing to node:18-alpine, current version is 18.18. Recommended version is v18.16.1.

When you run docker build with node:18-alpine it fails with error:

/opt/node_modules/sharp: Command failed.
38.06 Exit code: 127
38.06 Command: (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)
38.06 Arguments: 
38.06 Directory: /opt/node_modules/sharp
38.06 Output:
38.06 sharp: Detected globally-installed libvips v8.14.3
38.06 sharp: Building from source via node-gyp
38.06 /bin/sh: node-gyp: not found

To solve this change version of alpine node to node:18.16-alpine in all dockerfiles.

5 Likes

Did you solve this issue, I’m facing this issue too.

I solved this issue by adding RUN npm install -g node-gyp before yarn install.

Hello, yes. As i mentioned (last sentence):

To solve this change version of alpine node to node:18.16-alpine in all dockerfiles.

1 Like

downgrading to node:18.17-alpine seems to work for me

18.17.1 is a security release so I’m reluctant to downgrade below this

Can you say why the recommended version is 18.16.1 ?

1 Like

You are absolutely correct. What I meant by my comment was that at the time of writing (docs) the recommended version was LTS while at the time it was 18.16.1.

It is probalby better to use node:18.17-alpine. :slightly_smiling_face:

Sorry for my confusing description.

2 Likes

thanks @branislavballon

hopefully the node team will fix this in a later version and it will only be 18.18.0 that is broken (in fact it may only be this build or only this alpine version for all I can tell)

It seems like this is fixed in strapi Release v4.14.2 · strapi/strapi · GitHub

No changes made, re-publishing to fix NPM issues

1 Like

The problem seems to be an incompatibility with Python 3.11, but works well with Python 3.10.
The workaround that worked for me was to use FROM node:18.18-alpine3.17 or whatever alpine3.17 that works for you, as alpine 3.17 has Python 3.10 and alpine 3.18 has Python 3.11

1 Like

Thanks Tito - this has worked for me!