Skip to content

Commit 90b5b5b

Browse files
godcrampymaxdaytrivenay
committed
feat: Port Node.js 24.x runtime interface client implementation
Co-authored-by: Maxime David <maxday@amazon.com> Co-authored-by: Naman Trivedi <trivenay@amazon.com>
1 parent c2d6c2d commit 90b5b5b

File tree

161 files changed

+18486
-300
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

161 files changed

+18486
-300
lines changed

.gitignore

Lines changed: 15 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,17 @@
1-
build
2-
.DS_Store
3-
4-
test/integration/resources/init
5-
6-
# Logs
7-
logs
8-
*.log
9-
npm-debug.log*
10-
11-
# Diagnostic reports (https://nodejs.org/api/report.html)
12-
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
13-
14-
# Runtime data
15-
pids
16-
*.pid
17-
*.seed
18-
*.pid.lock
19-
20-
# Coverage directory used by tools like istanbul
21-
coverage
22-
*.lcov
23-
24-
# nyc test coverage
25-
.nyc_output
26-
27-
# Compiled binary addons (https://nodejs.org/api/addons.html)
28-
build/Release
29-
30-
# Dependency directories
31-
node_modules/
32-
33-
# Required for the async_init_with_node_modules unit test
34-
!test/handlers/async_init_with_node_modules/node_modules
35-
36-
# Optional npm cache directory
37-
.npm
38-
39-
# Optional eslint cache
1+
/node_modules
2+
/build
3+
/dist
4+
/coverage
5+
/build-artifacts/aws-lambda-ric*
6+
*.node
7+
/.byol
8+
.vscode
409
.eslintcache
41-
.eslintignore
42-
43-
# Output of 'npm pack'
44-
*.tgz
45-
46-
# Build
47-
dist/
48-
49-
# Stores VSCode versions used for testing VSCode extensions
50-
.vscode-test
51-
52-
deps/artifacts/
53-
deps/aws-lambda-cpp*/
54-
deps/curl*/
10+
/index.mjs
11+
.kiro/
12+
.DS_Store
5513

56-
# Local codebuild
57-
codebuild.*/
14+
# deps folder - track source archives, ignore build artifacts
15+
/deps/artifacts/
16+
/deps/curl-*/
17+
/deps/aws-lambda-cpp-*/

Dockerfile.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
FROM public.ecr.aws/amazonlinux/amazonlinux:2023
2+
3+
ARG TAG=latest
4+
ARG NODE_VERSION=22.14.0
5+
6+
RUN dnf -y install \
7+
gcc \
8+
gcc-c++ \
9+
jq \
10+
make \
11+
tar \
12+
xz \
13+
gzip \
14+
&& dnf clean all \
15+
&& rm -rf /var/cache/dnf \
16+
&& curl -fL https://nodejs.org/download/release/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-"$([[ "$(arch)" == "x86_64" ]] && echo "x64" || echo "arm64")".tar.xz | tar -C /usr --strip-components 1 -xJf - \
17+
&& node --version
18+
19+
# Copy dependencies from native build
20+
COPY --from=ric/nodejs-native:latest /deps.tar.gz /tmp/
21+
RUN mkdir -p /build && \
22+
tar xzf /tmp/deps.tar.gz -C /build && \
23+
ls -R /build/deps
24+
25+
# Copy bare config
26+
COPY package.json tsconfig.json eslint.config.js vitest.config.js vitest.setup.ts /app/
27+
28+
WORKDIR /app
29+
30+
RUN npm install
31+
32+
COPY src /app/src
33+
COPY scripts/build.js /app/scripts/build.js
34+
35+
# Build native module
36+
WORKDIR /app/src/native
37+
RUN DEPS_PREFIX=/build/deps npx node-gyp rebuild
38+
RUN cp build/Release/rapid-client.node /app/
39+
40+
# Build TypeScript
41+
WORKDIR /app
42+
RUN npm run build
43+
44+
# Create minimal package.json
45+
RUN jq '{name: .name, version: .version, license: .license, description: .description, main: .main, engines: .engines, type: .type, files: .files}' package.json > package.json.tmp && mv package.json.tmp package.json
46+
47+
# Package for distribution
48+
RUN npm pack

Dockerfile.lambda

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM public.ecr.aws/lambda/nodejs:24-preview
2+
3+
# Swap RIC
4+
ADD build-artifacts/aws-lambda-ric-*.tgz /tmp/
5+
RUN mv /tmp/package/* /var/runtime/ && rm -rf /tmp/package
6+
7+
COPY resources/index.mjs /var/task/
8+
9+
ENV LAMBDA_TASK_ROOT=/var/task
10+
ENV _HANDLER="index.handler"
11+
12+
CMD [ "index.handler" ]

Dockerfile.native

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
FROM public.ecr.aws/amazonlinux/amazonlinux:2023 as builder
2+
3+
ENV LD_LIBRARY_PATH=/var/lang/lib:$LD_LIBRARY_PATH
4+
5+
RUN dnf -y install \
6+
autoconf \
7+
automake \
8+
bsdtar \
9+
bzip2 \
10+
cmake \
11+
flex \
12+
gcc \
13+
gcc-c++ \
14+
gzip \
15+
libtool \
16+
make \
17+
patch \
18+
unzip \
19+
xz \
20+
&& dnf clean all \
21+
&& rm -rf /var/cache/dnf \
22+
&& mkdir -p /build/deps /tmp/curl /tmp/aws-lambda-cpp
23+
24+
# Add dependency source files
25+
COPY ./build-artifacts/curl.tar.xz /tmp/
26+
COPY ./build-artifacts/aws-lambda-cpp.tar.xz /tmp/
27+
28+
RUN cd /tmp && \
29+
tar -xf curl.tar.xz -C curl --strip-components=0 && \
30+
tar -xf aws-lambda-cpp.tar.xz -C aws-lambda-cpp --strip-components=0 && \
31+
ls -la /tmp/curl/
32+
33+
# Build curl
34+
WORKDIR /tmp/curl
35+
RUN autoreconf -fiv && \
36+
CFLAGS="$CURL_CFLAGS" LDFLAGS="$CURL_LDFLAGS" ./configure \
37+
--prefix /build/deps \
38+
--disable-alt-svc \
39+
--disable-ares \
40+
--disable-cookies \
41+
--disable-crypto-auth \
42+
--disable-dateparse \
43+
--disable-dict \
44+
--disable-dnsshuffle \
45+
--disable-doh \
46+
--disable-file \
47+
--disable-ftp \
48+
--disable-get-easy-options \
49+
--disable-gopher \
50+
--disable-hsts \
51+
--disable-http-auth \
52+
--disable-imap \
53+
--disable-ipv6 \
54+
--disable-ldap \
55+
--disable-ldaps \
56+
--disable-libcurl-option \
57+
--disable-manual \
58+
--disable-mime \
59+
--disable-mqtt \
60+
--disable-netrc \
61+
--disable-ntlm-wb \
62+
--disable-pop3 \
63+
--disable-progress-meter \
64+
--disable-proxy \
65+
--disable-pthreads \
66+
--disable-rtsp \
67+
--disable-shared \
68+
--disable-smtp \
69+
--disable-socketpair \
70+
--disable-sspi \
71+
--disable-telnet \
72+
--disable-tftp \
73+
--disable-threaded-resolver \
74+
--disable-unix-sockets \
75+
--disable-verbose \
76+
--disable-versioned-symbols \
77+
--with-pic \
78+
--without-brotli \
79+
--without-ca-bundle \
80+
--without-gssapi \
81+
--without-libidn2 \
82+
--without-libpsl \
83+
--without-librtmp \
84+
--without-libssh2 \
85+
--without-nghttp2 \
86+
--without-nghttp3 \
87+
--without-ngtcp2 \
88+
--without-ssl \
89+
--without-zlib \
90+
--without-zstd && \
91+
make -j "$(nproc)" && \
92+
make -j "$(nproc)" install
93+
94+
# Build AWS Lambda CPP
95+
WORKDIR /tmp/aws-lambda-cpp/build
96+
RUN LDFLAGS="$AWS_LAMBDA_CPP_LDFLAGS" cmake3 .. \
97+
-DCMAKE_CXX_FLAGS="-fPIC $AWS_LAMBDA_CPP_CXX_FLAGS" \
98+
-DCMAKE_INSTALL_PREFIX=/build/deps \
99+
-DCMAKE_MODULE_PATH=/build/deps/artifacts/lib/pkgconfig && \
100+
make -j "$(nproc)" && \
101+
make -j "$(nproc)" install
102+
103+
RUN tar czf /tmp/deps.tar.gz -C /build deps
104+
105+
FROM scratch
106+
COPY --from=builder /tmp/deps.tar.gz /deps.tar.gz

Dockerfile.peek

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM public.ecr.aws/amazonlinux/amazonlinux:2023
2+
3+
# Install Node.js and dependencies
4+
ARG NODE_VERSION=22.14.0
5+
6+
RUN dnf update -y && \
7+
dnf install -y \
8+
tar \
9+
xz \
10+
tree \
11+
vim \
12+
&& curl -fL https://nodejs.org/download/release/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-"$([[ "$(arch)" == "x86_64" ]] && echo "x64" || echo "arm64")".tar.xz | tar -C /usr --strip-components 1 -xJf -
13+
14+
COPY temp_extract/package /app
15+
16+
ENV AWS_LAMBDA_RUNTIME_API="127.0.0.1:8080"
17+
18+
WORKDIR /app

Dockerfile.rie

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM public.ecr.aws/lambda/nodejs:24-preview
2+
3+
# Swap RIC
4+
ADD build-artifacts/aws-lambda-ric-*.tgz /tmp/
5+
RUN mv /tmp/package/* /var/runtime/ && rm -rf /tmp/package
6+
7+
# Inject task
8+
ENV LAMBDA_TASK_ROOT="/var/task"
9+
COPY resources/index.cjs /var/task/
10+
ENV _HANDLER="index.handler"
11+
12+
ENTRYPOINT ["/usr/local/bin/aws-lambda-rie"]
13+
CMD ["/var/runtime/bootstrap"]

Dockerfile.rie.mc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM public.ecr.aws/lambda/nodejs:24-preview
2+
3+
# Copy MC RIE
4+
RUN mkdir -p /usr/local/bin/
5+
COPY bin/aws-lambda-rie /usr/local/bin/
6+
RUN chmod +x /usr/local/bin/aws-lambda-rie
7+
8+
# Swap RIC
9+
ADD build-artifacts/aws-lambda-ric-*.tgz /tmp/
10+
RUN mv /tmp/package/* /var/runtime/ && rm -rf /tmp/package
11+
12+
# Inject task
13+
ENV LAMBDA_TASK_ROOT="/var/task"
14+
COPY resources/index.cjs /var/task/
15+
ENV _HANDLER="index.handler"
16+
17+
# Set runtime API for local testing
18+
ENV AWS_LAMBDA_MAX_CONCURRENCY="2"
19+
ENV AWS_LAMBDA_NODEJS_WORKER_COUNT="8"
20+
21+
# Enable Verbose log
22+
ENV AWS_LAMBDA_RUNTIME_VERBOSE="1"
23+
24+
ENTRYPOINT ["/usr/local/bin/aws-lambda-rie"]
25+
CMD ["/var/runtime/bootstrap"]

Makefile

Lines changed: 10 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,17 @@
1-
target:
2-
$(info ${HELP_MESSAGE})
3-
@exit 0
4-
5-
init:
1+
build:
62
npm install
7-
8-
test:
9-
npm run test
10-
11-
copy-files:
12-
npm run copy-files
13-
14-
install:
15-
BUILD=$(BUILD) npm install
16-
17-
format:
18-
npm run format
19-
20-
# Command to run everytime you make changes to verify everything works
21-
dev: init test
22-
23-
# Verifications to run before sending a pull request
24-
pr: build dev
25-
26-
clean:
27-
npm run clean
28-
29-
build: copy-files
30-
make install BUILD=1
313
npm run build
324

33-
pack: build
34-
npm pack
35-
36-
.PHONY: target init test install format dev pr clean build pack copy-files
5+
test:
6+
npm test
377

38-
define HELP_MESSAGE
8+
integ:
9+
npm run test:integ
3910

40-
Usage: $ make [TARGETS]
11+
lint:
12+
npm run lint:fix
4113

42-
TARGETS
43-
format Run format to automatically update your code to match our formatting.
44-
build Builds the package.
45-
clean Cleans the working directory by removing built artifacts.
46-
dev Run all development tests after a change.
47-
init Initialize and install the dependencies and dev-dependencies for this project.
48-
pr Perform all checks before submitting a Pull Request.
49-
test Run the Unit tests.
14+
container:
15+
npm run build:container
5016

51-
endef
17+
.PHONY: build test integ lint container

0 commit comments

Comments
 (0)