Skip to content

ci: updated aws Lambda base image to node:20 #1728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 26, 2025
Merged

Conversation

aryamohanan
Copy link
Contributor

We already dropped support for Node.js 16 aws lambda runtime in the last major release, we missed to update the dockerfile.

Updated the base image in the Dockerfile to public.ecr.aws/lambda/nodejs:22 to align with the latest Node.js version for AWS Lambda.

@aryamohanan aryamohanan requested a review from a team as a code owner May 9, 2025 10:41
Copy link
Contributor

@kirrg001 kirrg001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For what are we using this Dockerfile?
And where do we reference this file?

@aryamohanan
Copy link
Contributor Author

For what are we using this Dockerfile? And where do we reference this file?

In my understanding, this docker image is the base image used when building the image for aws lambda, https://github.com/instana/nodejs/blob/main/packages/aws-lambda/layer/bin/publish-layer.sh#L376

@kirrg001
Copy link
Contributor

Yeah I saw this too, but I wasn't sure. But I can see a cd .., which navigates up to the Dockerfile 👍

I think we should pass the Node version as an argument.

docker build --build-arg NODEJS_VERSION=$NODEJS_VERSION . -t "$DOCKER_IMAGE_NAME:$VERSION"

Dockerfile

# see publish-layer.sh
ARG NODEJS_VERSION
FROM public.ecr.aws/lambda/nodejs:${NODEJS_VERSION}

This NODEJS_VERSION needs to be the version which is supported by our layer

--compatible-runtimes nodejs18.x nodejs20.x nodejs22.x \

Either we use our development version or define the version in the publish-layer script.


In general: It seems there is a poor support for Lambda layers in a Docker container. Because we only build the image with a specific AWS Lambda Node.js version always for the latest version. Our docs may need to make that clear. See https://www.ibm.com/docs/de/instana-observability/1.0.293?topic=lambda-aws-native-tracing-nodejs#instana-lambda-layer-for-container-based-functions

@kirrg001
Copy link
Contributor

I guess its good to do

supportedVersions="--compatible-runtimes nodejs18.x nodejs20.x nodejs22.x"
dockerNodeVersion="grab the lowest or highest supported node version from $supportedVersions"

@abhilash-sivan
Copy link
Contributor

+1 for using development version

@aryamohanan
Copy link
Contributor Author

As recommended, I have added the development version for the Docker image. Since v18 has already reached its end of life, and v22 officially added AWS support in November 2024, this update aligns with the current standards. Please share your thoughts

@aryamohanan aryamohanan requested a review from a team May 20, 2025 09:51
@aryamohanan aryamohanan changed the title ci: updated dockerfile to use v22 aws Lambda base image ci: updated aws Lambda base image to node:20 May 20, 2025
# The Node.js version to use for building the Docker image.
# This should be aligned with one of the supported runtimes above.
# We're using a development version.
NODE_VERSION_TO_BUILD="20"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we define the development version in a single constants file and reference it across all packages?
This would help improve maintainability since the version is repeated in multiple places.

P.S.: This might be out of scope for this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion, we can certainly consider doing that.

# The Node.js version to use for building the Docker image.
# This should be aligned with one of the supported runtimes above.
# We're using a development version.
NODE_VERSION_TO_BUILD="20"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason we are not using

NVMRC_PATH="$ROOT_DIR/.nvmrc"
NODEJS_VERSION=$(cat "$NVMRC_PATH")

?

Copy link
Contributor Author

@aryamohanan aryamohanan May 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good suggestion—I hadn't thought of it that way. I was only considering a generic file where we could define the version and use it everywhere. But reading from the .nvmrc file makes sense, especially since we're using the development version of Node for the images.

Copy link
Contributor

@kirrg001 kirrg001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pre-approving

@aryamohanan aryamohanan enabled auto-merge (squash) May 26, 2025 12:00
@aryamohanan aryamohanan disabled auto-merge May 26, 2025 12:00
@aryamohanan aryamohanan merged commit 645f8fd into main May 26, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants