Skip to content

Commit af9a4a3

Browse files
committed
Add nodejs18.x runtimes
1 parent 65c1f3d commit af9a4a3

File tree

17 files changed

+239
-11
lines changed

17 files changed

+239
-11
lines changed

README.md

+29-10
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ the [AWS CLI](https://aws.amazon.com/cli/).
3131
- [nodejs12.x](#nodejs12x)
3232
- [nodejs14.x](#nodejs14x)
3333
- [nodejs16.x](#nodejs16x)
34+
- [nodejs18.x](#nodejs18x)
3435
- [python3.8](#python38)
3536
- [python3.9](#python39)
3637
- [ruby2.7](#ruby27)
@@ -110,6 +111,24 @@ Build images
110111
| x86_64 | `mlupin/docker-lambda:nodejs16.x-build-x86_64` | `ghcr.io/mlupine/docker-lambda:nodejs16.x-build-x86_64` |
111112
| arm64 | `mlupin/docker-lambda:nodejs16.x-build-arm64` | `ghcr.io/mlupine/docker-lambda:nodejs16.x-build-arm64` |
112113

114+
### nodejs18.x
115+
116+
Runtime images
117+
118+
| Platform | Docker Hub | GitHub Container Registry |
119+
| --------- | ---------------------------------------- | ------------------------------------------------- |
120+
| Universal | `mlupin/docker-lambda:nodejs18.x` | `ghcr.io/mlupine/docker-lambda:nodejs18.x` |
121+
| x86_64 | `mlupin/docker-lambda:nodejs18.x-x86_64` | `ghcr.io/mlupine/docker-lambda:nodejs18.x-x86_64` |
122+
| arm64 | `mlupin/docker-lambda:nodejs18.x-arm64` | `ghcr.io/mlupine/docker-lambda:nodejs18.x-arm64` |
123+
124+
Build images
125+
126+
| Platform | Docker Hub | GitHub Container Registry |
127+
| --------- | ---------------------------------------------- | ------------------------------------------------------- |
128+
| Universal | `mlupin/docker-lambda:nodejs18.x-build` | `ghcr.io/mlupine/docker-lambda:nodejs18.x-build` |
129+
| x86_64 | `mlupin/docker-lambda:nodejs18.x-build-x86_64` | `ghcr.io/mlupine/docker-lambda:nodejs18.x-build-x86_64` |
130+
| arm64 | `mlupin/docker-lambda:nodejs18.x-build-arm64` | `ghcr.io/mlupine/docker-lambda:nodejs18.x-build-arm64` |
131+
113132

114133
### python3.8
115134

@@ -223,19 +242,19 @@ Build images
223242

224243
Runtime images
225244

226-
| Platform | Docker Hub | GitHub Container Registry |
227-
| --------- | ------------------------------------------- | ---------------------------------------------------- |
228-
| Universal | `mlupin/docker-lambda:dotnet6` | `ghcr.io/mlupine/docker-lambda:dotnet6` |
229-
| x86_64 | `mlupin/docker-lambda:dotnet6-x86_64` | `ghcr.io/mlupine/docker-lambda:dotnet6-x86_64` |
230-
| arm64 | `mlupin/docker-lambda:dotnet6-arm64` | `ghcr.io/mlupine/docker-lambda:dotnet6-arm64` |
245+
| Platform | Docker Hub | GitHub Container Registry |
246+
| --------- | ------------------------------------- | ---------------------------------------------- |
247+
| Universal | `mlupin/docker-lambda:dotnet6` | `ghcr.io/mlupine/docker-lambda:dotnet6` |
248+
| x86_64 | `mlupin/docker-lambda:dotnet6-x86_64` | `ghcr.io/mlupine/docker-lambda:dotnet6-x86_64` |
249+
| arm64 | `mlupin/docker-lambda:dotnet6-arm64` | `ghcr.io/mlupine/docker-lambda:dotnet6-arm64` |
231250

232251
Build images
233252

234-
| Platform | Docker Hub | GitHub Container Registry |
235-
| --------- | ------------------------------------------------- | ---------------------------------------------------------- |
236-
| Universal | `mlupin/docker-lambda:dotnet6-build` | `ghcr.io/mlupine/docker-lambda:dotnet6-build` |
237-
| x86_64 | `mlupin/docker-lambda:dotnet6-build-x86_64` | `ghcr.io/mlupine/docker-lambda:dotnet6-build-x86_64` |
238-
| arm64 | `mlupin/docker-lambda:dotnet6-build-arm64` | `ghcr.io/mlupine/docker-lambda:dotnet6-build-arm64` |
253+
| Platform | Docker Hub | GitHub Container Registry |
254+
| --------- | ------------------------------------------- | ---------------------------------------------------- |
255+
| Universal | `mlupin/docker-lambda:dotnet6-build` | `ghcr.io/mlupine/docker-lambda:dotnet6-build` |
256+
| x86_64 | `mlupin/docker-lambda:dotnet6-build-x86_64` | `ghcr.io/mlupine/docker-lambda:dotnet6-build-x86_64` |
257+
| arm64 | `mlupin/docker-lambda:dotnet6-build-arm64` | `ghcr.io/mlupine/docker-lambda:dotnet6-build-arm64` |
239258

240259
### provided.al2
241260

dump-fs/dump-nodejs18x/handler.js

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
const fs = require('fs')
2+
const { execSync } = require('child_process')
3+
const { S3Client, PutObjectCommand } = require("@aws-sdk/client-s3")
4+
const s3 = new S3Client({ region: 'eu-central-1' });
5+
6+
module.exports.handler_x86_64 = (async (e, c) => { return handler(e, c, "x86_64") })
7+
module.exports.handler_arm64 = (async (e, c) => { return handler(e, c, "arm64") })
8+
9+
handler = async (event, context, arch) => {
10+
const execOpts = { stdio: 'inherit', maxBuffer: 16 * 1024 * 1024 }
11+
12+
let filename = `nodejs18.x-${arch}.tgz`
13+
fs.closeSync(fs.openSync(`/tmp/${filename}`, 'w'))
14+
15+
let cmd = 'tar -cpzf /tmp/' + filename +
16+
' --numeric-owner --ignore-failed-read /var/runtime /var/lang /var/rapid'
17+
18+
execSync(cmd, execOpts)
19+
20+
console.log('Zipping done! Uploading...')
21+
22+
let data = await s3.send(new PutObjectCommand({
23+
Bucket: 'docker-lambda',
24+
Key: 'fs/' + filename,
25+
Body: fs.createReadStream('/tmp/' + filename),
26+
ACL: 'public-read',
27+
}))
28+
29+
console.log('Uploading done!')
30+
31+
console.log(process.execPath)
32+
console.log(process.execArgv)
33+
console.log(process.argv)
34+
console.log(process.cwd())
35+
console.log(__filename)
36+
console.log(process.env)
37+
execSync('echo /proc/1/environ; xargs -n 1 -0 < /proc/1/environ', execOpts)
38+
execSync("bash -O extglob -c 'for cmd in /proc/+([0-9])/cmdline; do echo $cmd; xargs -n 1 -0 < $cmd; done'", execOpts)
39+
console.log(context)
40+
41+
return data
42+
}

dump-fs/serverless.yml

+22-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
service: docker-lambda-dump
22

3-
frameworkVersion: "2"
3+
frameworkVersion: "3"
44

55
provider:
66
name: aws
@@ -262,3 +262,24 @@ functions:
262262
architecture: arm64
263263
layers:
264264
- { Ref: TarARMLambdaLayer }
265+
266+
dump-nodejs18x-x86_64:
267+
handler: dump-nodejs18x/handler.handler_x86_64
268+
package:
269+
patterns:
270+
- "!**"
271+
- "dump-nodejs18x/**"
272+
runtime: nodejs18.x
273+
architecture: x86_64
274+
layers:
275+
- { Ref: TarX86LambdaLayer }
276+
dump-nodejs18x-arm64:
277+
handler: dump-nodejs18x/handler.handler_arm64
278+
package:
279+
patterns:
280+
- "!**"
281+
- "dump-nodejs18x/**"
282+
runtime: nodejs18.x
283+
architecture: arm64
284+
layers:
285+
- { Ref: TarARMLambdaLayer }

examples/test-all.sh

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ cd ${EXAMPLES_DIR}/nodejs
88
docker run --rm -v "$PWD":/var/task mlupin/docker-lambda:nodejs12.x index.handler
99
docker run --rm -v "$PWD":/var/task mlupin/docker-lambda:nodejs14.x index.handler
1010
docker run --rm -v "$PWD":/var/task mlupin/docker-lambda:nodejs16.x index.handler
11+
docker run --rm -v "$PWD":/var/task mlupin/docker-lambda:nodejs18.x index.handler
1112

1213
cd ${EXAMPLES_DIR}/nodejs-native-module
1314
npm install

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,8 @@
1717
},
1818
"devDependencies": {
1919
"should": "^8.4.0"
20+
},
21+
"dependencies": {
22+
"serverless": "^3.25.1"
2023
}
2124
}
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM mlupin/docker-lambda:nodejs18.x-arm64
2+
3+
FROM mlupin/docker-lambda:build-arm64
4+
5+
ENV PATH=/var/lang/bin:$PATH \
6+
LD_LIBRARY_PATH=/var/lang/lib:$LD_LIBRARY_PATH \
7+
AWS_EXECUTION_ENV=AWS_Lambda_nodejs18.x \
8+
AWS_EXECUTION_ARCH=arm64 \
9+
NODE_PATH=/opt/nodejs/node18/node_modules:/opt/nodejs/node_modules:/var/runtime/node_modules
10+
11+
COPY --from=0 /var/runtime /var/runtime
12+
COPY --from=0 /var/lang /var/lang
13+
COPY --from=0 /var/rapid /var/rapid
14+
15+
# Add these as a separate layer as they get updated frequently
16+
RUN pipx install awscli==1.* && \
17+
pipx install aws-lambda-builders==1.23.1 && \
18+
pipx install aws-sam-cli==1.66.0
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
set -euxo pipefail
4+
5+
docker build --progress plain --squash -t mlupin/docker-lambda:nodejs18.x-build-arm64 .
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
set -euxo pipefail
4+
5+
export PUBLISH_DATE=$(date "+%Y%m%d%H%M")
6+
export NO_ARCH_TAG="mlupin/docker-lambda:nodejs18.x-build"
7+
export BASE_IMAGE="${NO_ARCH_TAG}-arm64"
8+
9+
docker tag ${BASE_IMAGE} ${BASE_IMAGE}-${PUBLISH_DATE}
10+
docker push ${BASE_IMAGE}
11+
docker push ${BASE_IMAGE}-${PUBLISH_DATE}
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM arm64v8/amazonlinux:2
2+
3+
RUN yum install -y tar gzip
4+
5+
RUN curl https://docker-lambda.s3.amazonaws.com/fs/nodejs18.x-arm64.tgz | tar -zx -C /opt
6+
7+
FROM mlupin/docker-lambda:provided.al2-arm64
8+
FROM mlupin/docker-lambda:base-arm64
9+
10+
ENV PATH=/var/lang/bin:$PATH \
11+
LD_LIBRARY_PATH=/var/lang/lib:$LD_LIBRARY_PATH \
12+
AWS_EXECUTION_ENV=AWS_Lambda_nodejs18.x \
13+
AWS_EXECUTION_ARCH=arm64
14+
15+
COPY --from=0 /opt/* /var/
16+
17+
COPY --from=1 /var/runtime/init /var/rapid/init
18+
19+
USER sbx_user1051
20+
21+
ENTRYPOINT ["/var/rapid/init", "--bootstrap", "/var/runtime/bootstrap", "--enable-msg-logs"]
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
set -euxo pipefail
4+
5+
docker build --progress plain --squash -t mlupin/docker-lambda:nodejs18.x-arm64 .
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
set -euxo pipefail
4+
5+
export PUBLISH_DATE=$(date "+%Y%m%d%H%M")
6+
export NO_ARCH_TAG="mlupin/docker-lambda:nodejs18.x"
7+
export BASE_IMAGE="${NO_ARCH_TAG}-arm64"
8+
9+
docker tag ${BASE_IMAGE} ${BASE_IMAGE}-${PUBLISH_DATE}
10+
docker push ${BASE_IMAGE}
11+
docker push ${BASE_IMAGE}-${PUBLISH_DATE}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM mlupin/docker-lambda:nodejs18.x-x86_64
2+
3+
FROM mlupin/docker-lambda:build-x86_64
4+
5+
ENV PATH=/var/lang/bin:$PATH \
6+
LD_LIBRARY_PATH=/var/lang/lib:$LD_LIBRARY_PATH \
7+
AWS_EXECUTION_ENV=AWS_Lambda_nodejs18.x \
8+
AWS_EXECUTION_ARCH=x86_64 \
9+
NODE_PATH=/opt/nodejs/node18/node_modules:/opt/nodejs/node_modules:/var/runtime/node_modules
10+
11+
COPY --from=0 /var/runtime /var/runtime
12+
COPY --from=0 /var/lang /var/lang
13+
COPY --from=0 /var/rapid /var/rapid
14+
15+
# Add these as a separate layer as they get updated frequently
16+
RUN pipx install awscli==1.* && \
17+
pipx install aws-lambda-builders==1.23.1 && \
18+
pipx install aws-sam-cli==1.66.0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
set -euxo pipefail
4+
5+
docker build --progress plain --squash -t mlupin/docker-lambda:nodejs18.x-build-x86_64 .
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
set -euxo pipefail
4+
5+
export PUBLISH_DATE=$(date "+%Y%m%d%H%M")
6+
export NO_ARCH_TAG="mlupin/docker-lambda:nodejs18.x-build"
7+
export BASE_IMAGE="${NO_ARCH_TAG}-x86_64"
8+
9+
docker tag ${BASE_IMAGE} ${BASE_IMAGE}-${PUBLISH_DATE}
10+
docker push ${BASE_IMAGE}
11+
docker push ${BASE_IMAGE}-${PUBLISH_DATE}
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM amd64/amazonlinux:2
2+
3+
RUN yum install -y tar gzip
4+
5+
RUN curl https://docker-lambda.s3.amazonaws.com/fs/nodejs18.x-x86_64.tgz | tar -zx -C /opt
6+
7+
FROM mlupin/docker-lambda:provided.al2-x86_64
8+
FROM mlupin/docker-lambda:base-x86_64
9+
10+
ENV PATH=/var/lang/bin:$PATH \
11+
LD_LIBRARY_PATH=/var/lang/lib:$LD_LIBRARY_PATH \
12+
AWS_EXECUTION_ENV=AWS_Lambda_nodejs18.x \
13+
AWS_EXECUTION_ARCH=x86_64
14+
15+
COPY --from=0 /opt/* /var/
16+
17+
COPY --from=1 /var/runtime/init /var/rapid/init
18+
19+
USER sbx_user1051
20+
21+
ENTRYPOINT ["/var/rapid/init", "--bootstrap", "/var/runtime/bootstrap", "--enable-msg-logs"]
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
set -euxo pipefail
4+
5+
docker build --progress plain --squash -t mlupin/docker-lambda:nodejs18.x-x86_64 .
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
set -euxo pipefail
4+
5+
export PUBLISH_DATE=$(date "+%Y%m%d%H%M")
6+
export NO_ARCH_TAG="mlupin/docker-lambda:nodejs18.x"
7+
export BASE_IMAGE="${NO_ARCH_TAG}-x86_64"
8+
9+
docker tag ${BASE_IMAGE} ${BASE_IMAGE}-${PUBLISH_DATE}
10+
docker push ${BASE_IMAGE}
11+
docker push ${BASE_IMAGE}-${PUBLISH_DATE}

0 commit comments

Comments
 (0)