'Cannot install sharp with Docker on M1 Mac
Installing sharp
on M1 Mac with yarn install
is OK, but with Docker results in the following error:
error /usr/src/app/node_modules/sharp: Command failed.
Exit code: 1
Command: (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)
Arguments:
Directory: /usr/src/app/node_modules/sharp
Output:
sharp: Installation error: Use with glibc 2.24 requires manual installation of libvips >= 8.11.3
sharp: Please see https://sharp.pixelplumbing.com/install for required dependencies
I ensured that sharp version is 0.29.0
, as well as installed lipvips globally on the Mac with brew install vips
however Docker still cannot build the app.
I followed the issue on GitHub https://github.com/lovell/sharp/issues/2460 but it didn't really help.
How could I force Docker to use that locally build lipvips? Or do you have any other suggestions? Thanks in advance
Solution 1:[1]
In dockerfile instead of Run npm install
, add following line
RUN SHARP_IGNORE_GLOBAL_LIBVIPS=1 npm install --arch=x64 --platform=linux sharp
Solution 2:[2]
Try setting export DOCKER_DEFAULT_PLATFORM=linux/amd64
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Jayesh Kulkarni |
Solution 2 | Scott Schulthess |