This AWS lambda layer contains a pre-built sharp npm library. It is optimized to reduce the total payload size.
| Sharp version | Layer size (zipped) | Lambda space usage |
|---|---|---|
| 0.26.0 | 33.3MB (10.2MB) |
A pre-built layer zip file is available at dist/sharp-layer.zip.
- Docker
-
Clone the repo:
git clone git@github.com:Umkus/lambda-layer-sharp.git cd lambda-layer-sharp/ -
Run Docker if it's not already.
-
Build
npm run build
This will install and then build within a
lambci/lambdadocker image. Then the compiled binaries will be copied todistand zip archived. Finally it will execute arequire. If the result output is function methods, then the build succeeded. -
Import created layer into your AWS account:
aws lambda publish-layer-version \ --layer-name sharp \ --description "Sharp layer for image resizer" \ --license-info "Apache License 2.0" \ --zip-file fileb://dist/sharp-layer.zip \ --compatible-runtimes nodejs12.x