Sharp: How to install sharp for AWS Lambda from musl-based Linux (Alpine, Void)

Created on 1 Mar 2019  路  2Comments  路  Source: lovell/sharp

Using Alpine Docker image to build and deploy AWS lambda function.

Trying this command to install proper pre-compiled binaries:

rm -rf node_modules/sharp && SHARP_IGNORE_GLOBAL_LIBVIPS=1 npm i --arch=x64 --platform=linux --target=8.10.0 sharp

But installation automatically detects Alpine Linux and downloads wrong binaries( musl )

Which leads to this error when running this lambda function:

{
  "errorMessage": "libc.musl-x86_64.so.1: cannot open shared object file: No such file or directory",
  "errorType": "Error",
  "stackTrace": [
    "Module.load (module.js:565:32)",
    "tryModuleLoad (module.js:505:12)",
    "Function.Module._load (module.js:497:3)",
    "Module.require (module.js:596:17)",
    "require (internal/module.js:11:18)",
    "bindings(/var/task/node_modules/bindings/bindings.js:112:48)",
    "Object.<anonymous> (/var/task/node_modules/sharp/lib/constructor.js:10:34)",
    "Module._compile (module.js:652:30)",
    "Object.Module._extensions..js (module.js:663:10)"
  ]
}

If there is a way to specify that I want to use specific binaries like libvips-8.7.0-linux-x64.tar.gz instead of libvips-8.7.0-linuxmusl-x64.tar.gz?

question

Most helpful comment

Hello, I'm not sure I understand the use of the musl-based Alpine to prepare code for the glibc-based AWS Lambda runtime environment. That's going to cause problems for any native dependencies, not just sharp.

All 2 comments

@lovell maybe it's possible to add family param in platform.js to allow a user to specify it in addition to auto-detection mechanism?

Hello, I'm not sure I understand the use of the musl-based Alpine to prepare code for the glibc-based AWS Lambda runtime environment. That's going to cause problems for any native dependencies, not just sharp.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kachurovskiy picture kachurovskiy  路  3Comments

genifycom picture genifycom  路  3Comments

janaz picture janaz  路  3Comments

OleVik picture OleVik  路  3Comments

paulieo10 picture paulieo10  路  3Comments