Skip to content

Commit 23449b8

Browse files
committed
chore: Update build-scripts and RIC dependencies
- Update Node.js Lambda base image from 24-preview to 24 stable release - Upgrade @aws/lambda-invoke-store from 0.2.0 to 0.2.2 - Downgrade package version from 4.1.0 to 4.0.0 - Add --ignore-scripts flag to npm install in Dockerfile.js - Rename build-artifacts directory references to deps in Dockerfile.native - Add deps directory to eslint ignore patterns - Enhance lambda-build.sh with architecture detection and validation - Add --provenance=false and --platform flags to docker build command - Implement architecture mismatch detection with function recreation logic
1 parent 90b5b5b commit 23449b8

File tree

9 files changed

+66
-23
lines changed

9 files changed

+66
-23
lines changed

Dockerfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ COPY package.json tsconfig.json eslint.config.js vitest.config.js vitest.setup.t
2727

2828
WORKDIR /app
2929

30-
RUN npm install
30+
RUN npm install --ignore-scripts
3131

3232
COPY src /app/src
3333
COPY scripts/build.js /app/scripts/build.js

Dockerfile.lambda

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM public.ecr.aws/lambda/nodejs:24-preview
1+
FROM public.ecr.aws/lambda/nodejs:24
22

33
# Swap RIC
44
ADD build-artifacts/aws-lambda-ric-*.tgz /tmp/

Dockerfile.native

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM public.ecr.aws/amazonlinux/amazonlinux:2023 as builder
1+
FROM public.ecr.aws/amazonlinux/amazonlinux:2023 AS builder
22

33
ENV LD_LIBRARY_PATH=/var/lang/lib:$LD_LIBRARY_PATH
44

@@ -22,8 +22,8 @@ RUN dnf -y install \
2222
&& mkdir -p /build/deps /tmp/curl /tmp/aws-lambda-cpp
2323

2424
# Add dependency source files
25-
COPY ./build-artifacts/curl.tar.xz /tmp/
26-
COPY ./build-artifacts/aws-lambda-cpp.tar.xz /tmp/
25+
COPY ./deps/curl.tar.xz /tmp/
26+
COPY ./deps/aws-lambda-cpp.tar.xz /tmp/
2727

2828
RUN cd /tmp && \
2929
tar -xf curl.tar.xz -C curl --strip-components=0 && \

Dockerfile.rie

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM public.ecr.aws/lambda/nodejs:24-preview
1+
FROM public.ecr.aws/lambda/nodejs:24
22

33
# Swap RIC
44
ADD build-artifacts/aws-lambda-ric-*.tgz /tmp/

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ The RIC includes a native C++ module for high-performance communication with the
170170
- [aws-lambda-cpp](https://github.com/awslabs/aws-lambda-cpp) - AWS Lambda C++ runtime
171171
- [curl](https://curl.se/) - HTTP client library
172172

173-
Pre-built archives for these dependencies are included in the `build-artifacts/` directory.
173+
Pre-built archives for these dependencies are included in the `deps/` directory.
174174

175175
## Contributing
176176

eslint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export default defineConfig([
2323
"node_modules/**",
2424
"build/**",
2525
"build-artifacts/**",
26+
"deps/**",
2627
"dist/**",
2728
"coverage/**",
2829
".byol/**",

package-lock.json

Lines changed: 7 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "aws-lambda-ric",
3-
"version": "4.1.0",
3+
"version": "4.0.0",
44
"description": "AWS Lambda Runtime Interface Client for Node.js",
55
"license": "Apache-2.0",
66
"repository": {
@@ -59,7 +59,7 @@
5959
"vitest": "^3.1.1"
6060
},
6161
"dependencies": {
62-
"@aws/lambda-invoke-store": "0.2.0",
62+
"@aws/lambda-invoke-store": "0.2.2",
6363
"node-addon-api": "^8.3.1",
6464
"node-gyp": "^11.2.0"
6565
}

scripts/lambda-build.sh

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,29 @@ if ! ls build-artifacts/aws-lambda-ric-*.tgz 1> /dev/null 2>&1; then
1717
exit 1
1818
fi
1919

20-
# Build Lambda image
21-
docker build -t ${IMAGE_NAME}:${TAG} -f Dockerfile.lambda .
20+
# Detect architecture from the Docker image that was built
21+
DOCKER_ARCH=$(docker inspect ric/nodejs-js:latest --format '{{.Architecture}}' 2>/dev/null || echo "")
22+
if [[ "$DOCKER_ARCH" == "arm64" ]]; then
23+
LAMBDA_ARCH="arm64"
24+
PLATFORM="linux/arm64"
25+
elif [[ "$DOCKER_ARCH" == "amd64" ]]; then
26+
LAMBDA_ARCH="x86_64"
27+
PLATFORM="linux/amd64"
28+
else
29+
# Fallback to host architecture
30+
HOST_ARCH=$(uname -m)
31+
if [[ "$HOST_ARCH" == "arm64" || "$HOST_ARCH" == "aarch64" ]]; then
32+
LAMBDA_ARCH="arm64"
33+
PLATFORM="linux/arm64"
34+
else
35+
LAMBDA_ARCH="x86_64"
36+
PLATFORM="linux/amd64"
37+
fi
38+
fi
39+
echo "Detected architecture: $LAMBDA_ARCH (platform: $PLATFORM)"
40+
41+
# Build Lambda image (--provenance=false ensures Docker v2 format compatible with Lambda)
42+
docker build --provenance=false --platform "${PLATFORM}" -t ${IMAGE_NAME}:${TAG} -f Dockerfile.lambda .
2243

2344
# Check if ECR repository exists, create if it doesn't
2445
if ! aws ecr describe-repositories --region ${AWS_REGION} --repository-names ${ECR_REPO_NAME} &> /dev/null; then
@@ -74,19 +95,39 @@ ROLE_ARN=$(aws iam get-role --region ${AWS_REGION} --role-name ${ROLE_NAME} --qu
7495

7596
# Check if the function exists
7697
if aws lambda get-function --region ${AWS_REGION} --function-name ${FUNCTION_NAME} &> /dev/null; then
77-
echo "Updating existing Lambda function ${FUNCTION_NAME}"
78-
aws lambda update-function-code \
79-
--region ${AWS_REGION} \
80-
--function-name ${FUNCTION_NAME} \
81-
--image-uri ${ECR_URI}/${ECR_REPO_NAME}:${TAG}
98+
# Check if architecture matches
99+
CURRENT_ARCH=$(aws lambda get-function-configuration --region ${AWS_REGION} --function-name ${FUNCTION_NAME} --query 'Architectures[0]' --output text)
100+
if [[ "$CURRENT_ARCH" != "$LAMBDA_ARCH" ]]; then
101+
echo "Architecture mismatch: Lambda is $CURRENT_ARCH, image is $LAMBDA_ARCH"
102+
echo "Deleting and recreating function with correct architecture..."
103+
aws lambda delete-function --region ${AWS_REGION} --function-name ${FUNCTION_NAME}
104+
sleep 5
105+
echo "Creating Lambda function ${FUNCTION_NAME} with architecture ${LAMBDA_ARCH}"
106+
aws lambda create-function \
107+
--region ${AWS_REGION} \
108+
--function-name ${FUNCTION_NAME} \
109+
--package-type Image \
110+
--code ImageUri=${ECR_URI}/${ECR_REPO_NAME}:${TAG} \
111+
--role ${ROLE_ARN} \
112+
--architectures ${LAMBDA_ARCH} \
113+
--timeout 30 \
114+
--memory-size 128
115+
else
116+
echo "Updating existing Lambda function ${FUNCTION_NAME}"
117+
aws lambda update-function-code \
118+
--region ${AWS_REGION} \
119+
--function-name ${FUNCTION_NAME} \
120+
--image-uri ${ECR_URI}/${ECR_REPO_NAME}:${TAG}
121+
fi
82122
else
83-
echo "Creating new Lambda function ${FUNCTION_NAME}"
123+
echo "Creating new Lambda function ${FUNCTION_NAME} with architecture ${LAMBDA_ARCH}"
84124
aws lambda create-function \
85125
--region ${AWS_REGION} \
86126
--function-name ${FUNCTION_NAME} \
87127
--package-type Image \
88128
--code ImageUri=${ECR_URI}/${ECR_REPO_NAME}:${TAG} \
89129
--role ${ROLE_ARN} \
130+
--architectures ${LAMBDA_ARCH} \
90131
--timeout 30 \
91132
--memory-size 128
92133
fi

0 commit comments

Comments
 (0)