From ea641fcae1c737677f526ce0d814d2fa29789f28 Mon Sep 17 00:00:00 2001 From: Hans Otto Wirtz Date: Fri, 16 Feb 2024 10:53:38 +0100 Subject: [PATCH 1/5] Upgrade to Node 18 --- Dockerfile | 2 +- README.md | 16 +--------------- package.json | 4 ++-- 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/Dockerfile b/Dockerfile index 70b06ea..b2fc650 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM amazonlinux:2-with-sources WORKDIR /build -RUN curl --silent --location https://rpm.nodesource.com/setup_16.x | bash - +RUN curl --silent --location https://rpm.nodesource.com/setup_18.x | bash - RUN yum -y install nodejs diff --git a/README.md b/README.md index e2346a2..05a81dd 100644 --- a/README.md +++ b/README.md @@ -22,21 +22,7 @@ A pre-built layer zip file is available on the [Releases page](https://github.co git clone git@github.com:bubblydoo/lambda-layer-sharp.git cd lambda-layer-sharp/ ``` -1. Install dependencies: - ```sh - docker run -v "$PWD":/var/task lambci/lambda:build-nodejs12.x npm --no-optional --no-audit --progress=false install - ``` -1. Build the layer: - ```sh - docker run -v "$PWD":/var/task lambci/lambda:build-nodejs12.x node ./node_modules/webpack/bin/webpack.js - ``` -1. Perform a smoke-test: - ```sh - docker run -w /var/task/dist/nodejs -v "$PWD":/var/task lambci/lambda:build-nodejs12.x node -e "console.log(require('sharp'))" - ``` -1. Import created layer into your AWS account: - ```sh - 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 +1. Build a multi-architecture Docker image: ``` ## Auto-publish diff --git a/package.json b/package.json index 61f5cf8..828fd84 100644 --- a/package.json +++ b/package.json @@ -13,9 +13,9 @@ "sharp": "latest" }, "engines": { - "node": ">=12.14.0" + "node": ">=18.0.0" }, "volta": { - "node": "16.16.0" + "node": "18.17.0" } } From c5f60da8aaf5fcbdb19334e1bd2be48930bb7a05 Mon Sep 17 00:00:00 2001 From: Hans Otto Wirtz Date: Fri, 16 Feb 2024 10:58:55 +0100 Subject: [PATCH 2/5] wip --- Dockerfile | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index b2fc650..a5870f9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,16 @@ +# Node 18 is not supported on https://serverfault.com/a/1141673 +FROM public.ecr.aws/lambda/nodejs:18 as nodesource + FROM amazonlinux:2-with-sources +ENV PATH="$PATH:/var/lang/bin" +COPY --from=nodesource /var/lang /var/lang + WORKDIR /build -RUN curl --silent --location https://rpm.nodesource.com/setup_18.x | bash - +# RUN curl --silent --location https://rpm.nodesource.com/setup_18.x | bash - -RUN yum -y install nodejs +# RUN yum -y install nodejs COPY * ./ From d60848736a78d2ea0cca8f30d53f1fe26731ed04 Mon Sep 17 00:00:00 2001 From: Hans Otto Wirtz Date: Fri, 16 Feb 2024 11:01:32 +0100 Subject: [PATCH 3/5] wip --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index a5870f9..f4498e4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,7 @@ FROM public.ecr.aws/lambda/nodejs:18 as nodesource FROM amazonlinux:2-with-sources ENV PATH="$PATH:/var/lang/bin" +ENV NODE_OPTIONS=--openssl-legacy-provider COPY --from=nodesource /var/lang /var/lang WORKDIR /build From 3641b7b5ff81b918f126d8ebee6634d583e62c80 Mon Sep 17 00:00:00 2001 From: Hans Otto Wirtz Date: Fri, 16 Feb 2024 11:05:19 +0100 Subject: [PATCH 4/5] wip --- Dockerfile | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index f4498e4..303339a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,10 @@ -# Node 18 is not supported on https://serverfault.com/a/1141673 -FROM public.ecr.aws/lambda/nodejs:18 as nodesource - -FROM amazonlinux:2-with-sources - -ENV PATH="$PATH:/var/lang/bin" -ENV NODE_OPTIONS=--openssl-legacy-provider -COPY --from=nodesource /var/lang /var/lang +FROM public.ecr.aws/amazonlinux/amazonlinux:2023 WORKDIR /build -# RUN curl --silent --location https://rpm.nodesource.com/setup_18.x | bash - +RUN curl --silent --location https://rpm.nodesource.com/setup_18.x | bash - -# RUN yum -y install nodejs +RUN yum -y install nodejs COPY * ./ From c5556569b9501f115691920a2db283fdb1b94120 Mon Sep 17 00:00:00 2001 From: Hans Otto Wirtz Date: Fri, 16 Feb 2024 11:08:46 +0100 Subject: [PATCH 5/5] wip --- Dockerfile | 2 ++ README.md | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/Dockerfile b/Dockerfile index 303339a..dfbfe83 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,7 @@ FROM public.ecr.aws/amazonlinux/amazonlinux:2023 +ENV NODE_OPTIONS=--openssl-legacy-provider + WORKDIR /build RUN curl --silent --location https://rpm.nodesource.com/setup_18.x | bash - diff --git a/README.md b/README.md index 05a81dd..00c61f6 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,10 @@ This AWS Lambda layer contains a pre-built [Sharp](https://www.npmjs.com/package A pre-built layer zip file is available on the [Releases page](https://github.com/bubblydoo/lambda-layer-sharp/releases), alongside the size of the layer. Zip files for both x86_64 and arm64 are available. +## Compatibility + +All versions above and including 0.33.0 are only compatible with Amazon Linux 2023 and Node.js 20 or above. + ## Build ### Dependencies