@@ -66,14 +66,63 @@ docker run -p 9000:8080 my-lambda-function
6666curl -XPOST " http://localhost:9000/2015-03-31/functions/function/invocations" -d ' {"message":"test"}'
6767```
6868
69+ ### Building on Custom Linux Distributions
70+
71+ You can build and run Lambda functions with the RIC on your own platform. Here's a minimal Dockerfile example:
72+
73+ ``` dockerfile
74+ FROM quay.io/centos/centos:stream9 AS build-image
75+
76+ ARG NODE_VERSION=22.14.0
77+ ARG FUNCTION_DIR="/function"
78+
79+ # Install build dependencies
80+ RUN dnf -y install \
81+ autoconf \
82+ automake \
83+ cmake \
84+ gcc \
85+ gcc-c++ \
86+ libtool \
87+ make \
88+ python3 \
89+ xz \
90+ && dnf clean all
91+
92+ # Install Node.js
93+ RUN ARCH=$(uname -m) && \
94+ if [ "$ARCH" = "x86_64" ]; then NODE_ARCH="x64" ; else NODE_ARCH="arm64" ; fi && \
95+ curl -fsSL https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-${NODE_ARCH}.tar.xz | \
96+ tar -xJ -C /usr/local --strip-components=1
97+
98+ # Create function directory
99+ RUN mkdir -p ${FUNCTION_DIR}
100+ WORKDIR ${FUNCTION_DIR}
101+
102+ RUN npm install aws-lambda-ric
103+
104+ ENTRYPOINT ["npx" , "aws-lambda-ric" ]
105+ CMD ["index.handler" ]
106+ ```
107+
108+ Build and run locally with RIE:
109+
110+ ``` bash
111+ docker build -t my-lambda .
112+ docker run -p 9000:8080 \
113+ -e AWS_LAMBDA_FUNCTION_NAME=test \
114+ -v ~ /.aws-lambda-rie:/aws-lambda \
115+ --entrypoint /aws-lambda/aws-lambda-rie \
116+ my-lambda npx aws-lambda-ric index.handler
117+ ```
118+
69119## Building from Source
70120
71121### Prerequisites
72122
73123- Node.js 22.x or later
74124- npm
75125- Docker (for container builds)
76- - Make
77126
78127### Local Development
79128
@@ -85,44 +134,56 @@ cd aws-lambda-nodejs-runtime-interface-client
85134# Install dependencies
86135npm install
87136
88- # Run tests
137+ # Run all tests with coverage and linting
89138npm test
90139
140+ # Run unit tests only
141+ npm run test:unit
142+
143+ # Run integration tests only
144+ npm run test:integ
145+
91146# Run linter
92147npm run lint
93148
94149# Fix linting issues
95150npm run lint:fix
96- ```
97151
98- ### Build Modes
152+ # Clean build artifacts
153+ npm run clean
154+ ```
99155
100- The project supports multiple build modes:
156+ ### Build Commands
101157
102- #### Metal Build ( Local Development)
158+ #### Local Build
103159
104- Fast build for local development and quick iterations :
160+ Build TypeScript and package for distribution :
105161
106162``` bash
107- npm run build:metal
163+ npm run build
108164```
109165
110- - TypeScript compilation only
111- - No native module compilation
112- - ~ 5 seconds build time
166+ This runs tests, compiles TypeScript, and packages the output.
167+
168+ Individual steps:
169+ ``` bash
170+ npm run compile # TypeScript compilation only
171+ npm run pkg # Package with esbuild
172+ ```
113173
114174#### Container Build (Full Build)
115175
116- Complete build including native module compilation:
176+ Complete build including native module compilation for Linux :
117177
118178``` bash
119179npm run build:container
120180```
121181
122182- Builds using Docker on AL2023 base image
123- - Compiles native C++ dependencies
124- - Produces deployable artifacts
125- - ~ 2-3 minutes build time
183+ - Compiles native C++ dependencies (curl, aws-lambda-cpp)
184+ - Produces deployable artifacts in ` build-artifacts/ `
185+ - Targets ` linux/amd64 ` by default for Lambda compatibility
186+ - Use ` PLATFORM=linux/arm64 npm run build:container ` for ARM64 Lambda
126187
127188### Testing with RIE
128189
@@ -139,6 +200,19 @@ npm run peek:rie
139200curl -XPOST " http://localhost:9000/2015-03-31/functions/function/invocations" -d ' {"message":"test"}'
140201```
141202
203+ For multi-concurrent testing:
204+ ``` bash
205+ npm run peek:rie:mc
206+ ```
207+
208+ ### Interactive Container Testing
209+
210+ To explore the built package in an interactive container:
211+
212+ ``` bash
213+ npm run peek:container
214+ ```
215+
142216### Testing in Lambda using Container Image
143217
144218To deploy and test as a Lambda container function:
@@ -149,7 +223,7 @@ npm run build:container
149223
150224# Review and update variables in scripts/lambda-build.sh
151225
152- # Build and deploy
226+ # Build and deploy (requires AWS credentials)
153227npm run peek:lambda
154228```
155229
0 commit comments