|
1 | 1 | # AWS Sharp layer
|
2 |
| -This AWS lambda layer contains a pre-built [sharp](https://www.npmjs.com/package/sharp) npm library. |
3 |
| -It is optimized for the most frugal space usage possible. |
| 2 | +This AWS lambda layer contains a pre-built [sharp](https://www.npmjs.com/package/sharp) npm library, so that you could "just use" it in your lambda code: |
4 | 3 |
|
5 |
| -# Getting |
6 |
| -A pre-built layer zip file is available on the [Releases page](../../releases), alongside the size of the layer. |
| 4 | +```javascript |
| 5 | +import sharp from 'sharp' |
| 6 | +// ... |
| 7 | +``` |
7 | 8 |
|
8 |
| -# Building |
| 9 | +It holds only necessary files to minimize its weight (16Mb). |
| 10 | +It also supports all currently supported AWS lambda node runtimes (>=`nodejs14.x`) and architectures (`x86_64` and `arm64`). |
9 | 11 |
|
10 |
| -## Dependencies |
11 |
| -* Docker |
| 12 | +# Getting |
| 13 | +A pre-built layer zip file is available on the [Releases page](../../releases). |
12 | 14 |
|
13 |
| -## Steps |
14 |
| -1. Clone the repo: |
15 |
| - ```shell script |
16 |
| - git clone git@github.com:Umkus/lambda-layer-sharp.git |
17 |
| - cd lambda-layer-sharp/ |
18 |
| - ``` |
19 |
| -1. Install dependencies: |
20 |
| - ```shell script |
21 |
| - docker run -v "$PWD":/var/task --entrypoint npm public.ecr.aws/lambda/nodejs:18 --no-audit --progress=false --arch=x64 --platform=linux ci |
22 |
| - ``` |
23 |
| -1. Build the layer: |
| 15 | +You can import it into your AWS account throught the Lambda console or with the following command: |
24 | 16 | ```shell script
|
25 |
| - docker run -v "$PWD":/var/task --entrypoint node public.ecr.aws/lambda/nodejs:18 ./node_modules/webpack/bin/webpack.js |
26 |
| - ``` |
27 |
| -1. Perform a smoke-test: |
28 |
| - ```shell script |
29 |
| - docker run -w /var/task/dist/nodejs -v "$PWD":/var/task --entrypoint node public.ecr.aws/lambda/nodejs:18 -e "console.log(require('sharp'))" |
30 |
| - ``` |
31 |
| -1. Import created layer into your AWS account: |
32 |
| - ```shell script |
33 |
| - 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 nodejs14.x nodejs16.x nodejs18.x |
| 17 | + 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 nodejs14.x nodejs16.x nodejs18.x --compatible-architectures x86_64 arm64 |
34 | 18 | ```
|
| 19 | + |
| 20 | +# Building |
| 21 | +Install dependencies (this will wipe your existing `node_modules/` directory): |
| 22 | +```shell script |
| 23 | +npm ci --arch=x64 --platform=linux |
| 24 | +``` |
| 25 | + |
| 26 | +Build will be performed automatically upon deps installation. |
0 commit comments