This AWS lambda layer contains a pre-built sharp npm library. It is optimized for the most frugal space usage possible.
Sharp version | Layer size |
---|---|
0.26.0 | 9.68MB |
A pre-built layer zip file is available at dist/sharp-layer.zip
.
- Docker
- Clone the repo:
git clone [email protected]:Umkus/lambda-layer-sharp.git cd lambda-layer-sharp/
- Install dependencies:
docker run -v "$PWD":/var/task lambci/lambda:build-nodejs12.x npm --no-optional --no-audit --progress=false install
- Build the layer:
docker run -v "$PWD":/var/task lambci/lambda:build-nodejs12.x node ./node_modules/webpack/bin/webpack.js
- Perform a smoke-test:
docker run -w /var/task/dist/nodejs -v "$PWD":/var/task lambci/lambda:build-nodejs12.x node -e "console.log(require('sharp'))"
- Import created layer into your AWS account:
aws lambda publish-layer-version --layer-name sharp --description "Sharp layer" --license-info "Apache License 2.0" --zip-file fileb://dist/sharp-layer.zip --compatible-runtimes nodejs12.x