-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[Question] Nodejs20-debian12 with aws-lambda-ric #1730
Comments
I'm a person with very little node knowledge, but could you just run the index.js in aws-lambda-ric directly? The ENTRYPOINT provided by distroless is and your CMD is |
I've played around with it, and it might not be possible with distroless because it expects FROM gcr.io/distroless/nodejs22-debian12:latest
COPY --from=public.ecr.aws/lambda/nodejs:22 /usr/local/bin/aws-lambda-rie /usr/local/bin/aws-lambda-rie
COPY --from=public.ecr.aws/lambda/nodejs:22 /var/runtime /var/runtime
ENV LAMBDA_TASK_ROOT=/var/task
WORKDIR /var/task
COPY index.js ${LAMBDA_TASK_ROOT}
ENTRYPOINT [ "/usr/local/bin/aws-lambda-rie" ]
CMD [ "/nodejs/bin/node", "/var/runtime/index.mjs" "index.handler" ] Where index.js is exports.handler = async (event) => {
const response = {
statusCode: 200,
body: JSON.stringify('Hello from Distroless Lambda!'),
};
return response;
}; And running it as docker run --rm -it -p 8080:8080 lambda And I get the following logs
If I somehow manage to sneak in
If I use the docker run --rm -it -p 8080:8080 --entrypoint /busybox/sh lambda And then run this inside the container /usr/local/bin/aws-lambda-rie /nodejs/bin/node /var/runtime/index.mjs index.handler I can actually curl it and get a response (takes a few tries, not sure if that's how it works, not familiar with AWS lambda). ❯ curl "http://localhost:8080/2015-03-31/functions/function/invocations" -d '{}'
{"statusCode":200,"body":"\"Hello from Distroless Lambda!\""} |
With some extra digging, I've come up with this FROM gcr.io/distroless/nodejs22-debian12:debug
COPY --from=public.ecr.aws/lambda/nodejs:22 /usr/local/bin/aws-lambda-rie /usr/local/bin/aws-lambda-rie
COPY --from=public.ecr.aws/lambda/nodejs:22 /var/runtime /var/runtime
ENV LAMBDA_TASK_ROOT=/var/task
WORKDIR /var/task
COPY index.js ${LAMBDA_TASK_ROOT}
COPY start.sh ${LAMBDA_TASK_ROOT}
ENTRYPOINT [ "/busybox/sh" ]
CMD [ "/var/task/start.sh" ] start.sh file /busybox/sh -c "/usr/local/bin/aws-lambda-rie /nodejs/bin/node /var/runtime/index.mjs index.handler" I can now start the container docker run --rm -it -p 8080:8080 lambda And curl it
|
Hey, we are currently running into issues while migrating onto an distroless image for our aws lambdas. I was following the docs from aws on how to use a non-AWS base image (https://docs.aws.amazon.com/lambda/latest/dg/nodejs-image.html#nodejs-image-clients).
Since the distroless image has removed package managers and everything else. NPM and NPX are not availabe. But I couldn't find any documentation what I could give as an entrypoint in the dockerfile for the aws-lambda-ric as an alternative. The documentation mentioned above expects the following entrypoint:
Do any of you have experience in what seems to be an edge case?
The text was updated successfully, but these errors were encountered: